• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSUIPC Question

Messages
12
Country
brazil
Hello,

I'm learning how to connect FS2004 to my C app using FSUIPC.

I obtained the MSFS Time but I coudn't get the Year, Month, Day and other vars... What am I doing wrong?

Code:
if (!FSUIPC_Read(0x238, 4, chTime, &dwResult) || !FSUIPC_Process(&dwResult)) {
          fTimeOk = FALSE;
}
...
...
...

if(fTimeOk) {
        printf("FS clock = %02d:%02d:%02d\n", chTime[0], chTime[1], chTime[2]);
}

I Found the code above at FSUIPC SDK so I tried to do the same using the Year offset (0x240)

Code:
if(!FSUIPC_Read(0x0240, 2, year, &dwResult) || !FSUIPC_Process(&dwResult)) {
	fYearOk = FALSE;
}

...
...


if(fYearOk) {
	printf("Year = %d %d\n", year[0], year[1]);
}


The console printed

FS clock = 07:25:22
Year = -40 7



Can someone help me?

thanks in advance.
 
I obtained the MSFS Time but I coudn't get the Year, Month, Day and other vars... What am I doing wrong?

FSUIPC_Read(0x0240, 2, year, &dwResult)

What is "year" defined as in your code? It should be either a 16-bit number ("short") or an "int" pre-initialised to 0, since you'll only be reading in the lower 2 bytes (16 bits).

printf("Year = %d %d\n", year[0], year[1]);

Er ... if you defined year as two characters (why?) then year[0] will be the low 8 bits and year[1] the high 8 bits. For 2008 (hex 0x07D8) the low 8 bits is 216 (0xD8) and the high 8 bits is 7.

Year = -40 7
There you go, then. You are using signed characters, so 216 comes out as -40 (216 - 256).

Please check some programming books and learn a little about numbers in programming. 16 bit numbers don't work too well in 8 bit compartments, and it wil be even worse if you ever progress to 32-bit and floating point (32 or 64 bit!).

Please also use the Logging facilities in FSUIPC to help debug your programs. That's what they are for!

Incidentally, you are lucky I saw this here. My support website is documented in all my publications. Please od go there in future. (Except I am just going on holiday for a couple of weeks :-) ).


Pete
 
Back
Top