2003-05-03 12:19:02 +00:00
|
|
|
The generic communication protocol for FlightGear provides a powerfull way
|
2006-04-29 11:14:36 +00:00
|
|
|
of adding a simple ASCII based or binary protocol, just by defining an
|
2003-05-03 12:19:02 +00:00
|
|
|
XML encoded configuration file.
|
|
|
|
|
2003-06-22 08:02:27 +00:00
|
|
|
The definition of the protocol consists of variable separators, line separators,
|
2003-05-03 12:19:02 +00:00
|
|
|
and chuncks of text.
|
|
|
|
|
|
|
|
Each chunck defines:
|
|
|
|
|
|
|
|
<name> for ease of use
|
|
|
|
<node> the property tree node which provides the data
|
|
|
|
<type> the value type (needed for formatting)
|
|
|
|
<format> defines the actual piece of text which should be sent.
|
|
|
|
it can include formatting options like:
|
|
|
|
<type>
|
|
|
|
%s string
|
|
|
|
%i integer (default)
|
|
|
|
%f float
|
2006-04-29 11:14:36 +00:00
|
|
|
(not used or needed in binary mode)
|
2003-05-03 12:19:02 +00:00
|
|
|
|
2006-04-29 11:14:36 +00:00
|
|
|
<factor> an optional multiplication factor which can be used for
|
2003-05-03 12:19:02 +00:00
|
|
|
unit conversion. (for example, radians to degrees).
|
|
|
|
<offset> an optional offset which can be used for unit conversion.
|
|
|
|
(for example, degrees Celsius to degrees Fahrenheit).
|
|
|
|
|
|
|
|
|
2003-06-22 08:02:27 +00:00
|
|
|
The output section also could define the variable separator and line separator.
|
2003-05-03 12:19:02 +00:00
|
|
|
|
2003-06-22 08:02:27 +00:00
|
|
|
The separators can be either a control character such as a tab or newline, or a
|
2003-05-03 12:19:02 +00:00
|
|
|
user specified string or other single charachter. The currently supported
|
|
|
|
control charachters are:
|
|
|
|
|
2003-06-22 08:02:27 +00:00
|
|
|
<var_separator>:
|
|
|
|
<line_separator>:
|
2003-05-03 12:19:02 +00:00
|
|
|
Name Charachter
|
|
|
|
|
|
|
|
newline '\n'
|
|
|
|
tab '\t'
|
|
|
|
formfeed '\f'
|
|
|
|
carriagereturn '\r'
|
|
|
|
verticaltab '\v'
|
|
|
|
|
|
|
|
any other charachters just need to be added to "Network/generic.cxx"
|
|
|
|
|
2003-06-22 08:02:27 +00:00
|
|
|
The var_separator is placed between each variable, while the line_separator is
|
2003-05-03 12:19:02 +00:00
|
|
|
placed at the end of each lot of variables.
|
|
|
|
|
2006-04-29 11:14:36 +00:00
|
|
|
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 -->
|
2003-05-03 12:19:02 +00:00
|
|
|
|
|
|
|
A simple protocol configuration file then could look something like the
|
|
|
|
following:
|
|
|
|
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<PropertyList>
|
|
|
|
|
|
|
|
<generic>
|
|
|
|
|
|
|
|
<output>
|
2003-06-22 08:02:27 +00:00
|
|
|
<line_separator>newline</line_separator>
|
|
|
|
<var_separator>newline</var_separator>
|
2006-04-29 11:14:36 +00:00
|
|
|
<binary_mode>false</binary_mode>
|
2003-05-03 12:19:02 +00:00
|
|
|
|
|
|
|
<chunk>
|
|
|
|
<name>speed</name>
|
|
|
|
<format>V=%d</format>
|
|
|
|
<node>/velocities/airspeed-kt</node>
|
|
|
|
</chunk>
|
|
|
|
|
|
|
|
<chunk>
|
|
|
|
<name>heading</name>
|
|
|
|
<format>H=%02d</format>
|
|
|
|
<node>/orientation/heading-deg</node>
|
|
|
|
<factor>57.29578</factor> <!-- radians to degrees -->
|
|
|
|
</chunk>
|
|
|
|
|
|
|
|
<chunk>
|
|
|
|
<name>pitch angle</name>
|
|
|
|
<format>P=%05.1f</format>
|
|
|
|
<type>float</type>
|
|
|
|
<node>/orientation/pitch-deg</node>
|
|
|
|
</chunk>
|
|
|
|
|
|
|
|
</generic>
|
|
|
|
|
|
|
|
</PropertyList>
|