Board index FlightGear Support Interfacing

Binary string from FG to Arduino

Connecting two computers, using generic protocol, connecting with Matlab?

Binary string from FG to Arduino

Postby felipetallabs » Thu Oct 08, 2020 7:39 pm

Hi

I am sending data from FG to Arduino in binary, using:

<binary_mode>true</binary_mode>
<byte_order>host</byte_order>

my question is, once it arrives in arduino, how to I convert it to decimal?

Thanks
felipetallabs
 
Posts: 13
Joined: Tue Jun 09, 2020 7:21 pm

Re: Binary string from FG to Arduino

Postby SE-HK » Fri Oct 09, 2020 12:27 am

By decimal, do you mean value with float precision?
Have you checked section Binary protocol parameters at http://wiki.flightgear.org/Generic_protocol?

If you do it binary I guess you must read 8 bytes and copy/shift into the variable, but I am not sure about any other need to convert the data. Perhaps you can find more info here: http://wiki.flightgear.org/Howto:Parsing_binary_data_received_via_UDP_in_C?
SE-HK
 
Posts: 54
Joined: Wed Sep 02, 2009 2:16 pm
Location: Stockholm, Sweden
Version: git
OS: Ubuntu 20.04

Re: Binary string from FG to Arduino

Postby felipetallabs » Fri Oct 09, 2020 1:57 am

Hi

Thanks for the response

I guess my question is:

My XML protocol in FG is sending constant values from a node, let's say one of the values is 0.379, for example, then I receive this number in Arduino as a Binary string, does the Arduino IDE convert this number back to float automatically? Or I have to do this myself in order to use this value in my protocol?

Thanks again

Felipe
felipetallabs
 
Posts: 13
Joined: Tue Jun 09, 2020 7:21 pm

Re: Binary string from FG to Arduino

Postby Volador » Sun Oct 11, 2020 7:33 pm

Hi felipetallabs, I think (from my limited understanding) you'll have to code the arduino to convert the binary, using a non-binary mode might make things easier in the arduino code unless you're creating a very large, complex system.
User avatar
Volador
 
Posts: 1142
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 3 guests