Jump to content
The simFlight Network Forums

some C++ vs FSUIPC request


Recommended Posts

Hy Pete,

I am having a bit of problems with the data types and conversion. (C++)

Could it be possible to get an example of a code which reads the NAV1 frequency from fsuipc and then puts it in a label or textbox ? That would be quite handy. The SDK example from C/C++ doesn't explain me really how to do that.

Link to comment
Share on other sites

Could it be possible to get an example of a code which reads the NAV1 frequency from fsuipc and then puts it in a label or textbox ? That would be quite handy. The SDK example from C/C++ doesn't explain me really how to do that.

What sort of explanation is really needed? The format of the frequencies is explained in the Programmer's guide. They are all simple 16 bit words -- i.e. type "unsigned short" both in C and C++. Read then into such (length 2).

They are in binary-coded decimal, which simply means that each group of 4 bits represents one decimal digit. For display it is easiest to simply convert them to hex character form, using the printf "%X" facility.

For instance, if the frequency is actually 112.75 the value you get, in hex, is 0x1275 (the 100 digit is assumed).

To print that you'd simply do a printf with "1%02X.%02X" (to put the decimal point in correctly), with parameters (val >> 8) and (val & 0xff).

None of this is complex programming, just basic C. (I don't know C++, sorry). If you can say why you cannot understand then maybe I can see what is wrong with the documentation, but having someone do the code for you doesn't help anyone in the long term.

Regards,

Pete

Link to comment
Share on other sites

Pete,

The info you gave helped someone else to give me some code which now works. So thanks for that.

You say that getting code is not helping one to understand or learn .. that's true .. but my phylosophy is that I don't need to knox exact how it works .. as long as it does work and I know how to mold it so that I can use it. After a while I understand by doing and using the code.

That's a total different approach than you suggest .. taking a book and learning 'bout program languages. But I think that would take me way too far and take me way too much time doing/learning things I don't need to know. It's a different phylosophy I guess.

Either way, the thing I want to acoumplishe is nearly finished and it'll work for me. So I'm happy.

Tnx

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.