Generic protocol: Difference between revisions

Jump to navigation Jump to search
Line 375: Line 375:
FlightGear has an inbuilt "generic" protocol to push and pull data. (todo)
FlightGear has an inbuilt "generic" protocol to push and pull data. (todo)


To interface with FlightGear on a socket for example, the following steps need to be taken.
To interface with FlightGear on a socket for example, the following steps need to be taken:
# Establish which "properties" you want to appear "on the wire"
# Establish which "properties" you want to appear "on the wire".
# Create a my_protocol.xml file containing those properties
# Create a <code>my_protocol.xml</code> file containing those properties.
# Start flight gear on a socket using my_protocol.
# Start FlightGear with the generic protocol option using <code>my_protocol</code> sent through the network socket.


For this simple example say were interested in heading and altitude, and we want to "listen" ie output to a socket at port 6789, udp and receiving 10 times a second in the format:
For this simple example say were interested in heading and altitude, and we want to "listen" ie output to a socket at port 6789, UDP and receiving 10 times a second in the format:
  alt\thead\n  
  alt\thead\n  
  // ie altitude - tab - heading - newline
  // ie altitude - tab - heading - newline
Line 391: Line 391:
  [[$FG_ROOT]]/Protocol/my_protocol.xml
  [[$FG_ROOT]]/Protocol/my_protocol.xml


The XML looks like this:
Edit the <code>my_protocol.xml</code> file and write in it:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <?xml version="1.0"?>
  <?xml version="1.0"?>
Line 420: Line 420:


* The '''output''' tag indicates the protocol for output. The same "protocol" file can contain an "input" section, absent in this example (more later).
* The '''output''' tag indicates the protocol for output. The same "protocol" file can contain an "input" section, absent in this example (more later).
* '''line_seperator''' - the end of line (todo ? is this \r\n??)
* '''line_seperator''' - the end of line (todo - is this <code>\r\n</code>?)
* '''var_seperator''' - the delimiter for the properties, this could be "|", "###", any string.
* '''var_seperator''' - the delimiter for the properties, this could be "|", "###", any string.
* The two '''chunk''' blocks contain our data. Note that these appear in the order presented within the xml file.
* The two '''chunk''' blocks contain our data. Note that these appear in the order presented within the XML file.
** '''node''' - the node of data we want
** '''node''' - the node of data we want
** '''name''' - it there for a reference, its not transmitted and note necessary (like a note)
** '''name''' - it there for a reference, its not transmitted and note necessary (like a note)
** '''type''' - the way this xml is to interpret the value. This is quite important tag. For example if its not there or a string, then "floats" go wild and end up being a string of 32 characters with two decimal places!
** '''type''' - the way this xml is to interpret the value. This is quite important tag. For example if its not there or a string, then "floats" go wild and end up being a string of 32 characters with two decimal places!
** '''format''' - same syntax as printf
** '''format''' - same syntax as <code>printf</code> function in C/C++
** There's more that can be done {todo - link to a full blown example/reference}
** There's more that can be done {todo - link to a full blown example/reference}


1,089

edits

Navigation menu