DesertStorm Posted January 20, 2020 Report Share Posted January 20, 2020 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) || !FSUIPC_Process(&dwResult)) { allOk = FALSE; } if (allOk) { printf("Flaps = %d\n", flaps[0]); } Sleep(100); n++; } } } 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. Thanks! Dani Link to comment Share on other sites More sharing options...
John Dowson Posted January 20, 2020 Report Share Posted January 20, 2020 Hi Dani, as the value is a 4 byte integer, try defining int flaps; and if (!FSUIPC_Read(0x0BDC, 4, &flaps, &dwResult)... ... printf("Flaps = %d\n", flaps); John P.S. For flaps position, you probably want offsets 0BE0 and 0BE4. Link to comment Share on other sites More sharing options...
DesertStorm Posted January 20, 2020 Author Report Share Posted January 20, 2020 Thankyou very much, I thought that fsuipc_read() only admitted char as a input, It works now! Again thankyou! Regards, Dani Link to comment Share on other sites More sharing options...
John Dowson Posted January 20, 2020 Report Share Posted January 20, 2020 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/ Regards, John Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now