Jump to content
The simFlight Network Forums

problem to read the Altitude of aircraft in 0x570


Recommended Posts

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.