Pete,
Just got up some courage to look inside Scott McCrory's C# library. Looks simple enough to add a FSUIPC_Get double method. However, he is using a builtin class called "Marshal" that can read the datatypes he provided methods for. The Marshal class does not have a method to read type double. This is what I have so far and where I'm stuck:
public bool FSUIPC_Get(ref int Token, ref double Result)
{
int Size = 8; // 8 bytes in a double
if ((Token < 0) || (Token > IPC_BUFFER_SIZE - (4 + Size)) )
{ //Token out of range
Result = 0;
return false;
}
IntPtr heapbuf = Marshal.AllocHGlobal(Size);
Marshal.Copy(IPC, Token + 4, heapbuf, Size);
Result = Marshal.Read??????(heapbuf);
Marshal.FreeHGlobal(heapbuf);
if (IPCdr[Token] )
{
IPCdr[Token] = false; // reset data ready flag
return true;
}
else
{ // if (data ready flag not set)
return false;
}
}
Marshal supports the following reads:
Marshal.ReadByte
Marshal.ReadInt16
Marshal.ReadInt32
Marshal.ReadInt64
Marshal.ReadIntPtr
So, I either need an example of how to call one of the existing methods that Scott provided (my original question on how to convert a byte[] to double) or I need an answer on how to add a FSUIPC_Get that takes a "double".
Thanks,
Jason