// Copyright (c) 2013 by István Váradi // This file is part of XPLRA, a remote-access plugin for X-Plane // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // 1. Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // The views and conclusions contained in the software and documentation are those // of the authors and should not be interpreted as representing official policies, // either expressed or implied, of the FreeBSD Project. #ifndef XPLRA_PROTOCOL_H #define XPLRA_PROTOCOL_H //------------------------------------------------------------------------------ namespace xplra { //------------------------------------------------------------------------------ /** * Constants and helpers for the protocol. */ class Protocol { public: /** * Command: get the value of a single dataref. */ static const uint8_t COMMAND_GET_SINGLE = 0x01; /** * Command: set the value of a single dataref. */ static const uint8_t COMMAND_SET_SINGLE = 0x02; /** * Command: get the value of a multiple datarefs. */ static const uint8_t COMMAND_GET_MULTI = 0x03; /** * Command: set the value of a multiple datarefs. */ static const uint8_t COMMAND_SET_MULTI = 0x04; /** * Command: register a multiple-data query request */ static const uint8_t COMMAND_REGISTER_GET_MULTI = 0x11; /** * Command: unregister a multiple-data query request */ static const uint8_t COMMAND_UNREGISTER_GET_MULTI = 0x12; /** * Command: execute a registered multiple-data query request */ static const uint8_t COMMAND_EXECUTE_GET_MULTI = 0x13; /** * Command: register a multiple-data update request */ static const uint8_t COMMAND_REGISTER_SET_MULTI = 0x21; /** * Command: unregister a multiple-data update request */ static const uint8_t COMMAND_UNREGISTER_SET_MULTI = 0x22; /** * Command: execute a registered multiple-data update request */ static const uint8_t COMMAND_EXECUTE_SET_MULTI = 0x23; /** * Command: get the versions of the simulator */ static const uint8_t COMMAND_GET_VERSIONS = 0x31; /** * Data type: int */ static const uint8_t TYPE_INT = 0x01; /** * Data type: float */ static const uint8_t TYPE_FLOAT = 0x02; /** * Data type: double */ static const uint8_t TYPE_DOUBLE = 0x03; /** * Data type: float array */ static const uint8_t TYPE_FLOAT_ARRAY = 0x11; /** * Data type: int array */ static const uint8_t TYPE_INT_ARRAY = 0x12; /** * Data type: byte array */ static const uint8_t TYPE_BYTE_ARRAY = 0x13; /** * Result code: no error, everything is OK. */ static const uint8_t RESULT_OK = 0x00; /** * Result code: invalid command */ static const uint8_t RESULT_INVALID_COMMAND = 0x01; /** * Result code: unknown dataref */ static const uint8_t RESULT_UNKNOWN_DATAREF = 0x02; /** * Result code: invalid type */ static const uint8_t RESULT_INVALID_TYPE = 0x03; /** * Result code: invalid length */ static const uint8_t RESULT_INVALID_LENGTH = 0x04; /** * Result code: invalid offset */ static const uint8_t RESULT_INVALID_OFFSET = 0x05; /** * Result code: invalid count */ static const uint8_t RESULT_INVALID_COUNT = 0x06; /** * Result code: invalid ID */ static const uint8_t RESULT_INVALID_ID = 0x07; /** * Result code: other error */ static const uint8_t RESULT_OTHER_ERROR = 0xff; /** * The maximal length we accept (in order to protect ourselves). */ static const int MAX_LENGTH = 2048; /** * The maximal count of requests in a multiple-data query or * update. */ static const size_t MAX_MULTI_COUNT = 1024; /** * The version of the plugin. */ static const int version = 10; }; //------------------------------------------------------------------------------ } /* namespace xplra */ //------------------------------------------------------------------------------ #endif // XPLRA_PROTOCOL_H // Local Variables: // mode: C++ // c-basic-offset: 4 // indent-tabs-mode: nil // End: