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
Diff: XPlaneUdp/XPlaneUdpEncoder.h
- Revision:
- 0:a5d13af495af
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/XPlaneUdp/XPlaneUdpEncoder.h Wed Dec 21 22:29:59 2011 +0000 @@ -0,0 +1,41 @@ +#ifndef XPLANEUDPENCODER_H_INCLUDED +#define XPLANEUDPENCODER_H_INCLUDED + +#include "XPlaneUdp.h" +#include "XPlaneUdpDATA.h" +#include "XPlaneUdpDATAMap.h" +#include "XPlaneUdpDREF.h" + +#define DATAREF_PACKET_SIZE 509 // "DREF" + '\x00' + 4-byte_value + 500-char_name + +class XPlaneUdpEncoder { +public: + + //XPlaneUdpEncoder(); + + void setDebug(bool debug); + + /** + * Encode a DATA packet from the messages in the given XPlaneUdpDATAMap. + * The encoded data will be placed at the location given by udpBuffer. + * If changedDataOnly is true, then only XPlaneUdpDATA messages with dataChanged will be encoded. + * Return number of bytes encoded into udpBuffer. + * Return -1 if there's more data in the map than what will fit in udpBuffer (> maxBufferLen). + */ + int encodeFromDATAMap(char * udpBuffer, int maxBufferLen, XPlaneUdpDATAMap & DATAMap, bool changedDataOnly); + + /** + * Encode a DataRef (DREF) packet, using the given DataRef. + * The encoded data will be placed at the location given by udpBuffer. + * Return number of bytes encoded into udpBuffer. + * Return -1 if there's more data in the map than what will fit in udpBuffer (> maxBufferLen). + */ + int encodeDataRef(char * udpBuffer, int maxBufferLen, XPlaneUdpDREF & dref); + +private: + + bool _debug; +}; + + +#endif // XPLANEUDPENCODER_H_INCLUDED