Re: [Flightgear-devel] Generic Protocol (generic.cxx etc) - Binary Mode
Any one had a chance to look over the patch yet?What needs to be changed/fixed/rewritten/redesigned(!) before it can be applied to the main CVS version?Hugo.On 4/25/06, Hugo Vincent [EMAIL PROTECTED] wrote: Thanks Erik,Here is the patch. Let me know what needs to be changed, fixed, orrefactored before it can go into CVS. Note that at this point, thebinary protocol is output only.Also attached is a really simple protocol to test the patch (bintest.xml). Run FGFS with:$ fgfs ... --generic=file,out,24,bintest_out,bintestAs well, there is a Python script (sorry, the script is a horribly dirtyhack) to decode and print the results. Execute it with: $ python test_decode.pyTo do list for the generic binary support:* use ntohl() etc to make the protocol independent of host endianess.* add CRC checksum as a possible packet footer* add binary input support * test thoroughlyCheers,Hugo VincentOn Mon, 2006-04-24 at 09:59 +0200, Erik Hofman wrote: Hugo Vincent wrote: I also updated OpenGC for this change and made a OpenGC.xml protocol file, but it appears the OpenGC project is more or less dead. Also, Network/opengc.cxx is a bit of a mess and seemingly unmaintained; it might be nice to get rid of it and replace it with a XML file at some stage. One approach is to directly replace opengc.cxx with an XML file that emulates the structure of the ogcFGData class, - however different compilers probably pad the variables in the class differently (for alignment/efficiency), so a patch to OpenGC does need to be made. If anyone wants the generic binary mode patch, or better yet, wants to add it into the main FlightGear repository, reply (to the list). Also, if anyone else has uses or requirements for binary protocols, let discuss them here, so that we can make generic binary support as broad and applicable as possible. I think it would be valuable, exactly for the reason mentioned above. Erik
Re: [Flightgear-devel] Generic Protocol (generic.cxx etc) - Binary Mode
Hugo Vincent wrote: Any one had a chance to look over the patch yet? What needs to be changed/fixed/rewritten/redesigned(!) before it can be applied to the main CVS version? No need to panic, If I have to apply it I just need some time to look over it and apply it. This may take a few days. Erik -- http://www.ehtw.info (Dutch)Future of Enschede Airport Twente http://www.ehofman.com/fgfs FlightGear Flight Simulator --- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel
Re: [Flightgear-devel] Generic Protocol (generic.cxx etc) - Binary Mode
Hugo Vincent wrote: I also updated OpenGC for this change and made a OpenGC.xml protocol file, but it appears the OpenGC project is more or less dead. Also, Network/opengc.cxx is a bit of a mess and seemingly unmaintained; it might be nice to get rid of it and replace it with a XML file at some stage. One approach is to directly replace opengc.cxx with an XML file that emulates the structure of the ogcFGData class, - however different compilers probably pad the variables in the class differently (for alignment/efficiency), so a patch to OpenGC does need to be made. If anyone wants the generic binary mode patch, or better yet, wants to add it into the main FlightGear repository, reply (to the list). Also, if anyone else has uses or requirements for binary protocols, let discuss them here, so that we can make generic binary support as broad and applicable as possible. I think it would be valuable, exactly for the reason mentioned above. Erik -- http://www.ehtw.info (Dutch)Future of Enschede Airport Twente http://www.ehofman.com/fgfs FlightGear Flight Simulator --- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel
Re: [Flightgear-devel] Generic Protocol (generic.cxx etc) - Binary Mode
Thanks Erik, Here is the patch. Let me know what needs to be changed, fixed, or refactored before it can go into CVS. Note that at this point, the binary protocol is output only. Also attached is a really simple protocol to test the patch (bintest.xml). Run FGFS with: $ fgfs ... --generic=file,out,24,bintest_out,bintest As well, there is a Python script (sorry, the script is a horribly dirty hack) to decode and print the results. Execute it with: $ python test_decode.py To do list for the generic binary support: * use ntohl() etc to make the protocol independent of host endianess. * add CRC checksum as a possible packet footer * add binary input support * test thoroughly Cheers, Hugo Vincent On Mon, 2006-04-24 at 09:59 +0200, Erik Hofman wrote: Hugo Vincent wrote: I also updated OpenGC for this change and made a OpenGC.xml protocol file, but it appears the OpenGC project is more or less dead. Also, Network/opengc.cxx is a bit of a mess and seemingly unmaintained; it might be nice to get rid of it and replace it with a XML file at some stage. One approach is to directly replace opengc.cxx with an XML file that emulates the structure of the ogcFGData class, - however different compilers probably pad the variables in the class differently (for alignment/efficiency), so a patch to OpenGC does need to be made. If anyone wants the generic binary mode patch, or better yet, wants to add it into the main FlightGear repository, reply (to the list). Also, if anyone else has uses or requirements for binary protocols, let discuss them here, so that we can make generic binary support as broad and applicable as possible. I think it would be valuable, exactly for the reason mentioned above. Erik bintest.xml Description: application/xml Index: Protocol/README.Protocol === RCS file: /var/cvs/FlightGear-0.9/data/Protocol/README.Protocol,v retrieving revision 1.2 diff -u -p -r1.2 README.Protocol --- Protocol/README.Protocol 22 Jun 2003 08:02:28 - 1.2 +++ Protocol/README.Protocol 25 Apr 2006 01:19:39 - @@ -1,5 +1,5 @@ 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. The definition of the protocol consists of variable separators, line separators, @@ -16,8 +16,9 @@ Each chunck defines: %s string %i integer (default) %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). offset an optional offset which can be used for unit conversion. (for example, degrees Celsius to degrees Fahrenheit). @@ -44,6 +45,16 @@ any other charachters just need to be ad The var_separator is placed between each variable, while the line_separator is placed at the end of each lot of variables. +To enable binary mode, simply include a binary_modetrue/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_footermagic,0x12345678/binary_footer + binary_footerlength/binary_footer + binary_footernone/binary_footer !-- default -- A simple protocol configuration file then could look something like the following: @@ -57,6 +68,7 @@ following: output line_separatornewline/line_separator var_separatornewline/var_separator + binary_modefalse/binary_mode chunk namespeed/name Index: src/Network/generic.cxx === RCS file: /var/cvs/FlightGear-0.9/source/src/Network/generic.cxx,v retrieving revision 1.17 diff -u -p -r1.17 generic.cxx --- src/Network/generic.cxx 9 Mar 2006 21:41:51 - 1.17 +++ src/Network/generic.cxx 25 Apr 2006 01:41:26 - @@ -79,51 +79,99 @@ FGGeneric::~FGGeneric() { // generate the message bool FGGeneric::gen_message() { - string generic_sentence; char tmp[255]; +length = 0; double val; for (unsigned int i = 0; i _out_message.size(); i++) { -if (i 0) +if (i 0 !binary_mode) generic_sentence += var_separator; switch (_out_message[i].type) { case FG_INT: val = _out_message[i].offset + _out_message[i].prop-getIntValue() * _out_message[i].factor; -snprintf(tmp, 255, _out_message[i].format.c_str(), (int)val); +if (binary_mode) { +
[Flightgear-devel] Generic Protocol (generic.cxx etc) - Binary Mode
Hi everyone, I am new to FlightGear and am using it for a UAV project (yep, yet another one - see http://www.albatross-uav.org). I need FlightGear to output binary-formatted data into UDP packets to support a custom protocol used in the system (that is, to have data from FlightGear look like data coming from the UAV, to test the ground station software etc.). There has been talk on the mailing list before (e.g. here: http://www.opensubscriber.com/message/flightgear-devel@flightgear.org/1750238.html by Michael Meyers) about added binary support to the generic protocol, but it seems nothing was done about it. I added basic binary mode support to Network/generic.cxx that is enabled with a binary_modetrue/binary_mode tag in the protocol XML file. The patch is quite small, and if the binary_mode tag is not found it does not fail (meaning any existing protocol XML files continue to work). As well as supporting simple packed binary output, configurable data can be added at the end of each packet (aka line in ASCII protocols), such as a magic number, or the length of the packet. Other things like a CRC checksum of the packet could be added easily. I also updated OpenGC for this change and made a OpenGC.xml protocol file, but it appears the OpenGC project is more or less dead. Also, Network/opengc.cxx is a bit of a mess and seemingly unmaintained; it might be nice to get rid of it and replace it with a XML file at some stage. One approach is to directly replace opengc.cxx with an XML file that emulates the structure of the ogcFGData class, - however different compilers probably pad the variables in the class differently (for alignment/efficiency), so a patch to OpenGC does need to be made. If anyone wants the generic binary mode patch, or better yet, wants to add it into the main FlightGear repository, reply (to the list). Also, if anyone else has uses or requirements for binary protocols, let discuss them here, so that we can make generic binary support as broad and applicable as possible. Cheers, Hugo Vincent. --- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel