The xplane_io (X-Plane I/O) program is used to establish network communications, via UDP, with the X-Plane flight simulator running on a computer. The code consists of class libraries that abstract the lower-level UDP packet encoding and decoding details, according to the UDP protocol specifications in X-Plane version 9. Any X-Plane DATA packets can be sent and received, and any X-Plane DataRefs can be set by sending DREF packets to X-Plane.

Dependencies:   EthernetNetIf mbed ConfigFile

Revision:
0:a5d13af495af
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XPlaneUdp/XPlaneUdpDecoder.h	Wed Dec 21 22:29:59 2011 +0000
@@ -0,0 +1,43 @@
+#ifndef XPLANEUDPDECODER_H_INCLUDED
+#define XPLANEUDPDECODER_H_INCLUDED
+
+#include "XPlaneUdp.h"
+#include "XPlaneUdpDATA.h"
+#include "XPlaneUdpDATAMap.h"
+
+class XPlaneUdpDecoder {
+public:
+
+    //XPlaneUdpDecoder();
+    
+    void setDebug(bool debug);
+    void setReverseByteOrder(bool reverseByteOrder);
+
+    /**
+     * This must be called prior to other methods such as putIntoDATAMap().
+     * Point this decoder to the UDP data buffer, and read the first four bytes
+     * to determine the X-Plane UDP message type (e.g. DATA).
+     */
+    XPlaneUdpMessageType setUdpBuffer(char * buf, int bufLen);
+    
+    /**
+     * Note: The setUdpBuffer() method must be called prior to calling this method.
+     * Decode the UDP packet. If it is a DATA packet from X-Plane, then populate
+     * XPlaneUdpDATA structure(s) in the map.
+     * If filter==true, then only existing structures in the map (keyed by message DATA msg index)
+     * will be populated, i.e. no new structures will be created in the map.
+     * Return the number of XPlaneUdpDATA structures populated/updated in the map.
+     */
+    int putIntoDATAMap(XPlaneUdpDATAMap & DATAMap, bool filter);
+
+private:
+
+    bool _debug;
+    bool _reverseByteOrder;
+    char *_udpBuffer;
+    int _udpBufferLen;
+    XPlaneUdpMessageType _udpPacketMsgType;
+};
+
+
+#endif // XPLANEUDPDECODER_H_INCLUDED