Jump to content
The simFlight Network Forums

Question about C programming for FSX data capturer

Recommended Posts

Hi all! It's my first time in this forum, I'm Dani, aerospace engineer from Spain and a general aviation cockpit builder using IOcards. My apologies if my English is not good.

I'm trying to make a little data capturer written in C in order to gather some data from FSX and I'm having some issues with some offsets. I'm following the C example of the SDK, but I think not all the offsets works in the same way and is the cause I'm not getting the correct values.

If I try to get size 1 variables, for example "fuel pump", "pitot heat", etc, I get the correct values: no problems.


But if the sizes are greater than 1, I can't obtain any reasonable value. Normally I obtained a mix of positive and negative values. I will put an example of what I'm doing, if its helpful:

In this code I'm trying to get the "0 to 16383" range of flaps. But I obtained for the FSX cessna 172, the following values: 0, 85, -86, -1 for each of the 4 positions.

Same happens with the gear trim and for all of diferent than 1 byte size variables, All what I obtain is random values with no sense.

I suppose I'm doing something terribly wrong but I have tried not to get away a lot of the C example of the SDK, more or less is the same structure (I added the 25 times bucle).


#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "FSUIPC_User.h"

int main()
	DWORD dwResult;

	if (FSUIPC_Open(SIM_ANY, &dwResult))
		char flaps[4];
		BOOL allOk = TRUE;
		int n = 0;
		while (n<25)
			if (!FSUIPC_Read(0x0BDC, 4, flaps, &dwResult) ||

				allOk = FALSE;

			if (allOk)
				printf("Flaps = %d\n", flaps[0]);



I have tried also to read using flaps [1], [2], and [3] but with worst results, because in the C example of the SDK you read [0] [1] and [2] to obtain hours minutes and seconds. Also I tried to use %s instead %d, and so many combinations.

Can you please provide any extra information of what I'm doing wrong to try to better understand the working of the C FSUIPC programming? My goal will be to obtain the values that comes on the offset status pdf, to after convert it to engineer values as I do in my work with ARINC protocols in real planes.




Link to comment
Share on other sites

It accepts a memory address, with the size as the second parameter (also offset size). You should define it to be the type you are actually reading.
You should also maybe check-out Paul Henty's client dll for .net / c#, as this provides a higher level abstraction that many folks find easier to use (although its for c#).
See https://forum.simflight.com/forum/167-fsuipc-client-dll-for-net/



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.