On Sun, 7 Aug 2011, Derrick Washington wrote: > Hi > > I need to know if the inputs coming from FG, while using a generic > protocol having binary mode set to true, are coming in as integers that need > to be converted to floating point or is FG actually sending in a floating > point word, a byte at a time? So my code to receive FG data looks something > like this.... > > > for ( int i = 0; i <= 3; i++ ) { dummy_var = (dummy_var << 8) | > rs232_uart1; } > > > > return ( (float) dummy_var); > > What I am wondering is, is the " return ( (float) dummy_var); " cast to a > float necessary, or is the number already in floating point format, if so > then I need to instruct my hardware to retrieve a full word at a time. I've > included the xml file just in case you guys have any questions about what > data I am asking FG to transmit.
FlightGear sends the float value one byte at the time, so the cast to float is not correct since that will convert the int value in dummy_var to a float rather than accepting the bit pattern it contains as a float value. One way to do the latter is this: return *(float *)&dummy_var; C++ may have nicer ways. Cheers, Anders -- --------------------------------------------------------------------------- Anders Gidenstam WWW: http://www.gidenstam.org/FlightGear/ ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1 _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel