Jump to content
The simFlight Network Forums

Newbie FSIPU programming question


Recommended Posts

Hello Peter - I'm a newbie FSIPCU programmer and was hoping that you can help me with a simple sample.

I would like to read, printf the value, then write the value to the airplane HEADING offset at 0x580.

I'm currently looking through the sample UIPCHello.c code. I guess I'm just looking for a small code snippet that shows the pvoid set-up, then the FSUIPC_ code to do this - this small bit would help me get started..

Thank you for your time.

Link to comment
Share on other sites

I would like to read, printf the value, then write the value to the airplane HEADING offset at 0x580.

I don't do actual code for folks. That's programming and you should really be a programmer before you start, especially if you are considering using C or C++.

But it is easy enough to describe. Do an FSUIPC_Read from 0x580 (4 bytes long) into a variable declared as an "unsigned int", then call FSUIPC_Process to make it happen. Printf the value times 360.0 and divided by (65536.0 * 65536.0) as a floating point number (a double, using the %f formatter).

I'm currently looking through the sample UIPCHello.c code. I guess I'm just looking for a small code snippet that shows the pvoid set-up

Ah. Then what don't you understand about the Hello example? What do you mean about a "pvoid setup" -- sorry, that doesn't really mean anything. You don't set up any "pvoids". You make a pointer to your Heading value, declared as an "unsigned int" by taking its name and prepending & (eg &heading). Please refer to your C reference books for C syntax. You do need that first.

If there's something you don't understand which I should be explaining in the SDK, the please be more explicit. Then I know how to improve it. But actually writing the code for you would be a mistake I think. I ought to be finding out why you cannot do it and advising on that. If it is just that you've never used C or C++ before then I would really advise programming something simpler than an FS application first.

Let me know.

Regards,

Pete

Link to comment
Share on other sites

Thanks for the help....I can get the heading to work now -

One thing I'm not sure about is the calculation to degrees - I've used your calculation (X * 360/ (65536*65536)) - for a unsigned int heading value of 905415551, the resulting degree is 75.89 (I checked this against FSInterrogate which gives the same number) However, when I look at the heading panel in FS2004, it reads 62 degrees.

Do you know why there is a difference?

Thank you for your time

Link to comment
Share on other sites

for a unsigned int heading value of 905415551, the resulting degree is 75.89 (I checked this against FSInterrogate which gives the same number) However, when I look at the heading panel in FS2004, it reads 62 degrees.

Do you know why there is a difference?

That'll be the magnetic variation, which is different in different places. The heading you are reading is relative to True North, the one shown in aircraft instrumentation is related to Magnetic North. You can get the Mag Var from FSUIPC at offset 02A0. Note that this is only a 16-bit (2 byte) value, so read it into a "short" variable, and scale is as described before adjusting the heading for Magnetic. The variation is signed.

Regards,

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.