Firstly, thanks Pete for the awesome module of FSUIPC that you have written and documented so well.
I am, however, stuck on something. I have been struggeling for days to get this to work but to no avail. I am trying to write the AP Altitude value into offset 07D4. From the numerous examples for C#, the values written are inserted statically. So for writing 30000, I used your provided calculations and got to the 32bit value of 599261164.8236427, rounded off to 599261165. When I put this into the write function it works like a charm and updates the AP altitude to 30000 as expected. However, I can't get it to accept a variable.
What I've tried so far is to convert the double variable to a byte array and then write each of the 4 bytes seperately to each offset, i.e. alt for offset 07D4, alt for offset 07D5, etc.
That didnt work. When I try to assign the double to a byte, it gives me an overflow error (which I expected) cause the value is way too large for a byte.
How do I get around this? I would really appreciate any help on this.
Here is a code snippet:
double apaltset; byte temp2; byte temp3; apaltset = (30000 / 3.28084) * 65536.0; apaltset = Math.Round(apaltset); temp3 = BitConverter.GetBytes(apaltset); temp2 = (byte) apaltset //value too large for byte //result = fsuipc.FSUIPC_Write(0x07D4, 599261164, ref token, ref dwResult); //this works result = fsuipc.FSUIPC_Write(0x07D4, temp3, ref token, ref dwResult); //doesn't except a byte result = fsuipc.FSUIPC_Process(ref dwResult);