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.

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.