Jump to content
The simFlight Network Forums

lueckmw

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by lueckmw

  1. Ah, it finally clicked as to what's going on there. Thanks for your help. Matt
  2. Writing it all at once as an 8 byte chunck didn't seem to make any difference, but I did notice that if I multiply by (65536 * 65536) it works properly. After looking back at vdkeybus's code, I noticed he multiplied by that (MAXINT) rather than just 65536. I guess this basically moves the important part of the number to the upper 2 bytes of the 4 byte chunk. I don't really understand why that works, but it does, so I'm not complaining. According to the log it still reads back 00 00 for the lower 2 bytes, which it claimed that it wrote during the previous write. At any rate, it seems to work. Here's the function I ended up with (I call FSUIPC_Process after the function returns): void setAltitude(DWORD *pdwResult, double Altitude) { static struct { unsigned int lval; int hval; } val; val.hval=(int)floor(Altitude); val.lval=(unsigned int)((Altitude-val.hval)*65536*65536); FSUIPC_Write(0x0570, 8, &val, pdwResult); }
  3. I'm trying to write a function to set altitude and I came across this thread. I've pretty much using vdkeybus's function, but I can't get it to work. After I write the two words, I read them back and print them out. It reads back the correct value for the upper word, but the fractional portion is zero. When I checked the log, it appears to be writing the correct value, but it reads back all zeros. Here's a section of the log file: 24703 WRITE0 0570, 4 bytes: 8F 02 00 00 24703 WRITE0 0574, 4 bytes: D3 00 00 00 24703 READ0 0570, 4 bytes: 00 00 00 00 24703 READ0 0574, 4 bytes: D3 00 00 00 Here's my function: void setAltitude(DWORD *pdwResult, double Altitude) { unsigned int altLowerTemp; int altUpperTemp; static struct { unsigned lval; int hval; } val; val.hval=(int)floor(Altitude); val.lval=(unsigned)((Altitude-val.hval)*65536); printf("decimal value = %f\n", Altitude-val.hval); printf("alt lower wrote = %d\n", val.lval); printf("alt upper wrote = %d\n", val.hval); FSUIPC_Write(0x0570, 4, &val.lval, pdwResult); FSUIPC_Write(0x0574, 4, &val.hval, pdwResult); FSUIPC_Process(pdwResult); FSUIPC_Read(0x0570, 4, &altLowerTemp, pdwResult); FSUIPC_Read(0x0574, 4, &altUpperTemp, pdwResult); FSUIPC_Process(pdwResult); printf("alt lower read = %d\n", altLowerTemp); printf("alt upper read = %d\n\n", altUpperTemp); } Am I missing something simple here? Thanks for your help. Matt
×
×
  • 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.