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
XPlaneUdp/XPlaneUdpDecoder.h@0:a5d13af495af, 2011-12-21 (annotated)
- Committer:
- bapowell
- Date:
- Wed Dec 21 22:29:59 2011 +0000
- Revision:
- 0:a5d13af495af
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bapowell | 0:a5d13af495af | 1 | #ifndef XPLANEUDPDECODER_H_INCLUDED |
bapowell | 0:a5d13af495af | 2 | #define XPLANEUDPDECODER_H_INCLUDED |
bapowell | 0:a5d13af495af | 3 | |
bapowell | 0:a5d13af495af | 4 | #include "XPlaneUdp.h" |
bapowell | 0:a5d13af495af | 5 | #include "XPlaneUdpDATA.h" |
bapowell | 0:a5d13af495af | 6 | #include "XPlaneUdpDATAMap.h" |
bapowell | 0:a5d13af495af | 7 | |
bapowell | 0:a5d13af495af | 8 | class XPlaneUdpDecoder { |
bapowell | 0:a5d13af495af | 9 | public: |
bapowell | 0:a5d13af495af | 10 | |
bapowell | 0:a5d13af495af | 11 | //XPlaneUdpDecoder(); |
bapowell | 0:a5d13af495af | 12 | |
bapowell | 0:a5d13af495af | 13 | void setDebug(bool debug); |
bapowell | 0:a5d13af495af | 14 | void setReverseByteOrder(bool reverseByteOrder); |
bapowell | 0:a5d13af495af | 15 | |
bapowell | 0:a5d13af495af | 16 | /** |
bapowell | 0:a5d13af495af | 17 | * This must be called prior to other methods such as putIntoDATAMap(). |
bapowell | 0:a5d13af495af | 18 | * Point this decoder to the UDP data buffer, and read the first four bytes |
bapowell | 0:a5d13af495af | 19 | * to determine the X-Plane UDP message type (e.g. DATA). |
bapowell | 0:a5d13af495af | 20 | */ |
bapowell | 0:a5d13af495af | 21 | XPlaneUdpMessageType setUdpBuffer(char * buf, int bufLen); |
bapowell | 0:a5d13af495af | 22 | |
bapowell | 0:a5d13af495af | 23 | /** |
bapowell | 0:a5d13af495af | 24 | * Note: The setUdpBuffer() method must be called prior to calling this method. |
bapowell | 0:a5d13af495af | 25 | * Decode the UDP packet. If it is a DATA packet from X-Plane, then populate |
bapowell | 0:a5d13af495af | 26 | * XPlaneUdpDATA structure(s) in the map. |
bapowell | 0:a5d13af495af | 27 | * If filter==true, then only existing structures in the map (keyed by message DATA msg index) |
bapowell | 0:a5d13af495af | 28 | * will be populated, i.e. no new structures will be created in the map. |
bapowell | 0:a5d13af495af | 29 | * Return the number of XPlaneUdpDATA structures populated/updated in the map. |
bapowell | 0:a5d13af495af | 30 | */ |
bapowell | 0:a5d13af495af | 31 | int putIntoDATAMap(XPlaneUdpDATAMap & DATAMap, bool filter); |
bapowell | 0:a5d13af495af | 32 | |
bapowell | 0:a5d13af495af | 33 | private: |
bapowell | 0:a5d13af495af | 34 | |
bapowell | 0:a5d13af495af | 35 | bool _debug; |
bapowell | 0:a5d13af495af | 36 | bool _reverseByteOrder; |
bapowell | 0:a5d13af495af | 37 | char *_udpBuffer; |
bapowell | 0:a5d13af495af | 38 | int _udpBufferLen; |
bapowell | 0:a5d13af495af | 39 | XPlaneUdpMessageType _udpPacketMsgType; |
bapowell | 0:a5d13af495af | 40 | }; |
bapowell | 0:a5d13af495af | 41 | |
bapowell | 0:a5d13af495af | 42 | |
bapowell | 0:a5d13af495af | 43 | #endif // XPLANEUDPDECODER_H_INCLUDED |