The generic communication protocol for FlightGear provides a powerful way of adding a simple ASCII based or binary input/output protocol, just by defining an XML encoded configuration file and placing it in the $FG_ROOT/data/Protocols/ directory. == file layout ================================================================ A protocol file can contain either or both of and definition blocks. Which one is used depends on how the protocol is called (e.g. --generic=file,out,1,/tmp/data.xml,myproto would only use the definitions block). false ... first chunk spec ... ... another chunk etc. ... ... chunk spec ... == input/output parameters ==================================================== Both and blocks can contain information about the data mode (ascii/binary) and about separators between fields and data sets, as well as a list of s. Each defines a property that should be written (and how), or a variable and which property it should be written to. output only: BOOL default: false (= ASCII mode) STRING default: "" file header put on top of the file STRING default: "" file footer put at the end of the file input & output: STRING default: "" field separator STRING default: "" separator between data sets are put between every two output properties, while is put at the end of each data set. Both can contain arbitrary strings or one of the following keywords: Name Character newline '\n' tab '\t' formfeed '\f' carriagereturn '\r' verticaltab '\v' Typical use could be: tab newline or \t \r\n To enable binary mode, simply include a true 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 tag. Options include the length of the packet, a magic number to simplify decoding. Examples: magic,0x12345678 length none == variable parameters (chunk spec) =========================================== Both and block can contain a list of specs, each of which describes the properties of on variable to write/read. for ease of use (not tranferred) the property tree node which provides the data the value type (needed for formatting) one of string, float, bool, int (default: int) defines the actual piece of text which should be sent. it can include "printf" style formatting options like: %s string %d integer (default) %f float (not used or needed in binary mode) an optional multiplication factor which can be used for unit conversion. (for example, radians to degrees). an optional offset which can be used for unit conversion. (for example, degrees to radians). Chunks can also consist of a single constant , like in: == examples =================================================================== Writes log of this form: V=1736 H=17647 P=004.6 V=1780 H=18105 P=006.4 newline newline false speed V=%d /velocities/airspeed-kt heading (rad) H=%.6f float /orientation/heading-deg 0.0174532925199433 pitch angle (deg) P=%03.2f /orientation/pitch-deg -- writing data in XML syntax ------------------------------------------------- Assuming the file is called $FG_ROOT/Protocols/xmltest.xml, then it could be used as $ fgfs --generic=file,out,1,/tmp/data.xml,xmltest false <?xml version="1.0"?>\n\n<data>\n </data>\n \t<set>\n /position/altitude-ft float \t\t<altitude-ft>%.8f</altitude-ft>\n /velocities/airspeed-kt float \t\t<airspeed-kt>%.8f</airspeed-kt>\n \t</set>\n