Jump to content
The simFlight Network Forums

Offsets Formats


Recommended Posts

Some offsets specify the numerical format of the value in the offset, but others do not. Just for example, the offset for Indicated airspeed shows:

02BC   4   IAS: Indicated Air Speed, as knots * 128

So the question that comes up is should this 4 byte (32 bit ) value be read using ipc.readSD(), ipc.readUD(), or ipc.readFLT()? 

Since the format is not specified for this offset (while the format for some other offsets are) is there an implication that any of the above ipc.read instructions will work and the Lua interpreter will make the necessary conversion,  or do you have to read and display the value to see what it looks like, or what? Would appreciate any general guidance for these type of situations.

Thanks,

Al

Link to comment
Share on other sites

1 hour ago, ark1320 said:

02BC   4   IAS: Indicated Air Speed, as knots * 128

So the question that comes up is should this 4 byte (32 bit ) value be read using ipc.readSD(), ipc.readUD(), or ipc.readFLT()? 

If you think you might one day see a negative airspeed maybe you would read it as an SD. But i don't think it is possible in the Sim. So it's best really as a UD.  For positive numbers the only difference bretween a uD and an SD is the maximum value, as the top bit is reserved as the sign.

Floating point and double values are always noted as such. All others are integers in some format or other.

1 hour ago, ark1320 said:

there an implication that any of the above ipc.read instructions will work and the Lua interpreter will make the necessary conversion

No, a plug-in has no idea what the data is supposed to mean, so it can't do anything automatically like that.

Pete

 

 

Link to comment
Share on other sites

30 minutes ago, Pete Dowson said:

Floating point and double values are always noted as such. All others are integers in some format or other.

I assume the above means all single and double floating point values are noted as such, and all others are integers.

Thank you, very helpful!

Al

Link to comment
Share on other sites

Quote

I assume the above means all single and double floating point values are noted as such, and all others are integers.

Yes. "single floating points" are called Floats (FLOAT or FLOAT32) whereas the Doubles are called DOUBLE or even FLOAT64.

Note also that some "integers" are really fixed point values, eg the integer in the high part and fraction in the low part, with the point considered to be at the boundary. But these variations are always described.

This mish-mash is historical. FSUIPC started with FSW95 as a program by Adam Szofran of Microsoft -- I took over with FS98 and later. In the early days FS was designed with memory constraints considered, and data was kept in its most compact form, using units and formats which gave the maximum precision for the least space, at least for all values for which a range or boundary could be determined.

As versions of FS developed this was relaxed, but my ambition with FSUIPC was on-going compatibility with as many of the add-on programs as possible. So, new data formats for new programs but don't stop the older ones working. So FSUIPC still converts most values to their old formats, even though SimConnect supplies (or can be asked to supply) them almost all in standard forms (usually doubles for numerical values, for example). In many cases FSUIPC now supplies values more than once, in different forms.

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.