cyberflygo Posted November 24, 2009 Report Share Posted November 24, 2009 Hi,peter. I have a problem while convert the Altitude of aircraft to feet. Example ,the Altitude of aircraft is 440 feet ,i read the 0x570 ,result is 3833856000, 3833856000*3.28084/(65536*65536)=2.92. read the gps Altitude (0x6020) also can't convert to a correct value. can you help me? thanks. Link to comment Share on other sites More sharing options...
Pete Dowson Posted November 24, 2009 Report Share Posted November 24, 2009 Hi,peter. I have a problem while convert the Altitude of aircraft to feet. Example ,the Altitude of aircraft is 440 feet ,i read the 0x570 ,result is 3833856000, 3833856000*3.28084/(65536*65536)=2.92. read the gps Altitude (0x6020) also can't convert to a correct value. can you help me? thanks. You are not reading the correct offset, or you have another error, then. Use FSInterrogate to compare what you are reading with the correct value. FSInterrogate can display it in hex, decimal and it will do the computations too. Pete Link to comment Share on other sites More sharing options...
cyberflygo Posted November 26, 2009 Author Report Share Posted November 26, 2009 I found the reason! I use FSInterrogate to read the 0x570 ,the value is 566473064448 HEX:83E46D0000 hex viewer offest 0001 0203 0405 0607 0x570 0000 6DE4 8300 0000 use the fsuipc read the frist part 0x570 ,value is E46D0000 ,read the second part 0x574 ,value is 83。 I don't know how to connect the two part into the rally value. Link to comment Share on other sites More sharing options...
Pete Dowson Posted November 26, 2009 Report Share Posted November 26, 2009 I found the reason!... use the fsuipc read the frist part 0x570 ,value is E46D0000 ,read the second part 0x574 ,value is 83。 ... I don't know how to connect the two part into the rally value. So you were only reading 4 bytes, not 8? It does say it is an 8-byte (64-bit) value. How did you know to divide by (65536*65536) if you didn't know you had the fractional part? For example, if this: i read the 0x570 ,result is 3833856000, 3833856000*3.28084/(65536*65536)=2.92 was talking about the fractional part, then you already have that: in metres the fraction is 2.92/3.28084. (Naturally the fractional part can't be as much as 1 metre). So if the integer part is, say, 53 metres, the whole answer is 53 + (2.92/3.28084) metres, or 53 * 3.28084 + 2.92 feet. This works okay provided the altitude is always zero or positive. If the integer is negative, so too will be the fraction, so you would subtract the fraction, not add it. It is actually much easier if the compiler / language you are using contains 64-bit integer facilities. Then simply read the 8 bytes into a 64-bit integer and then do the calculations as you were. In MSC/C++ a 64-bit integer is defined by __int64. I think also "long long" works in some compilers. Pete Link to comment Share on other sites More sharing options...
cyberflygo Posted November 27, 2009 Author Report Share Posted November 27, 2009 yes ,used the _int64 can get the full 64-bit value.thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now