1
0
Fork 0

Add support for a binary output mode.

This commit is contained in:
ehofman 2006-04-29 11:14:36 +00:00
parent c9035a46d8
commit 1d75ec0639
2 changed files with 65 additions and 2 deletions

View file

@ -1,5 +1,5 @@
The generic communication protocol for FlightGear provides a powerfull way The generic communication protocol for FlightGear provides a powerfull way
of adding a simple ASCII based output only protocol, just by defining an of adding a simple ASCII based or binary protocol, just by defining an
XML encoded configuration file. XML encoded configuration file.
The definition of the protocol consists of variable separators, line separators, The definition of the protocol consists of variable separators, line separators,
@ -16,8 +16,9 @@ Each chunck defines:
%s string %s string
%i integer (default) %i integer (default)
%f float %f float
(not used or needed in binary mode)
<factor> an optionale multiplication factor which can be used for <factor> an optional multiplication factor which can be used for
unit conversion. (for example, radians to degrees). unit conversion. (for example, radians to degrees).
<offset> an optional offset which can be used for unit conversion. <offset> an optional offset which can be used for unit conversion.
(for example, degrees Celsius to degrees Fahrenheit). (for example, degrees Celsius to degrees Fahrenheit).
@ -44,6 +45,16 @@ any other charachters just need to be added to "Network/generic.cxx"
The var_separator is placed between each variable, while the line_separator is The var_separator is placed between each variable, while the line_separator is
placed at the end of each lot of variables. placed at the end of each lot of variables.
To enable binary mode, simply include a <binary_mode>true</binary_mode> tag in
your XML file. The format of the binary output is tightly packed, with 1 byte
for bool, 4 bytes for int, and 8 bytes for double. At this time, strings are not
supported. A configurable footer at the end of each "line" or packet of binary
output can be added using the <binary_footer> tag. Options include the length
of the packet, a magic number to simplify decoding. Examples:
<binary_footer>magic,0x12345678</binary_footer>
<binary_footer>length</binary_footer>
<binary_footer>none</binary_footer> <!-- default -->
A simple protocol configuration file then could look something like the A simple protocol configuration file then could look something like the
following: following:
@ -57,6 +68,7 @@ following:
<output> <output>
<line_separator>newline</line_separator> <line_separator>newline</line_separator>
<var_separator>newline</var_separator> <var_separator>newline</var_separator>
<binary_mode>false</binary_mode>
<chunk> <chunk>
<name>speed</name> <name>speed</name>

51
Protocol/bintest.xml Normal file
View file

@ -0,0 +1,51 @@
<?xml version="1.0"?>
<PropertyList>
<generic>
<output>
<binary_mode>true</binary_mode>
<binary_footer>magic,0x12345678</binary_footer>
<chunk>
<name>indicated speed (kt)</name>
<type>int</type>
<node>/velocities/airspeed-kt</node>
</chunk>
<chunk>
<name>pitch att (deg)</name>
<type>float</type>
<node>/orientation/pitch-deg</node>
</chunk>
<chunk>
<name>magnetic heading (deg)</name>
<type>float</type>
<node>/orientation/heading-deg</node>
</chunk>
<chunk>
<name>outside air temperarure (degF)</name>
<type>int</type>
<node>/environment/temperature-degf</node>
</chunk>
<chunk>
<name>autocoord</name>
<type>boolean</type>
<node>/sim/auto-coordination</node>
</chunk>
<chunk>
<name>clock</name>
<type>string</type>
<node>/instrumentation/clock/indicated-string</node>
</chunk>
</output>
</generic>
</PropertyList>