[67] | 1 | /*! \mainpage X-Plane Remote Access Plugin and Client Library Documentation
|
---|
| 2 | *
|
---|
| 3 | * \section intro Introduction
|
---|
| 4 | *
|
---|
| 5 | * The X-Plane Remote Access (XPLRA) plugin provides a gateway to external
|
---|
| 6 | * applications to access some internals of X-Plane. This document
|
---|
| 7 | * describes the plugin and its usage. It is assumed that the reader
|
---|
| 8 | * is somewhat familiar with the X-Plane plugin SDK. The plugin
|
---|
| 9 | * currently works on Linux and Windows, but porting to Mac should be
|
---|
| 10 | * easy. If you would volunteer, let me know! :)
|
---|
| 11 | *
|
---|
| 12 | * The XPLRA plugin allows the extern applications to perform the
|
---|
| 13 | * following:
|
---|
| 14 | * - Get and set the values of datarefs either individually or in
|
---|
| 15 | * batch. Batches can also be pre-registered in case the same set of
|
---|
| 16 | * datarefs is to be queried or modified several times. This avoids
|
---|
| 17 | * having to send and resolve the dataref names every time.
|
---|
| 18 | * - Query the versions of X-Plane, XPLM (the plugin manager) and
|
---|
| 19 | * XPLRA.
|
---|
| 20 | * - Show a message in a window for the pilot for a specified amount
|
---|
| 21 | * of time.
|
---|
| 22 | * - Register and then monitor hotkeys.
|
---|
| 23 | *
|
---|
| 24 | * Currently the plugin can be accessed locally, i.e. from the same
|
---|
| 25 | * computer that runs X-Plane, but extending it with TCP/IP-based or
|
---|
| 26 | * network access would not be difficult. While client libraries are
|
---|
[70] | 27 | * provided for \ref cppapi "C, C++" and \ref pythonapi "Python",
|
---|
[69] | 28 | * the communication protocol between clients and the plugin is open
|
---|
| 29 | * and is \ref proto "described" in this documentation. So you can
|
---|
| 30 | * write your own client library, if you wish.
|
---|
[67] | 31 | */
|
---|
| 32 | /*! \page proto Protocol
|
---|
| 33 | *
|
---|
| 34 | * On Linux a Unix stream socket is created with the name
|
---|
| 35 | * \c /tmp/xplra-\<user name\>, where \c \<user name\> is the login
|
---|
| 36 | * account name of the user running X-Plane. On Windows a named pipe
|
---|
| 37 | * is created with the name \c \\\\\.\\pipe\\xplra. The usual methods
|
---|
| 38 | * provided by the OS can be used to connect to these.
|
---|
| 39 | *
|
---|
| 40 | * The protocol is a binary protocol. The client initiates commands
|
---|
| 41 | * which are executed by the plugin. Each command is a byte followed
|
---|
| 42 | * by the arguments of the command. The plugin responds with a result
|
---|
| 43 | * code, which is also a byte, which may be followed by the rest of
|
---|
| 44 | * the reply, e.g. the data queried or a parameter to an error code.
|
---|
| 45 | *
|
---|
[68] | 46 | * \section protodata Types of protocol data elements
|
---|
[67] | 47 | *
|
---|
| 48 | * The protocol's basic data elements are: 8-, 16- and 32-bit signed
|
---|
| 49 | * and unsigned integers, single and double precision floating point
|
---|
| 50 | * values and strings. The endianness of the values is that of the
|
---|
| 51 | * host operating system.
|
---|
| 52 |
|
---|
| 53 | * Strings are encoded as a variable-length length followed by as many
|
---|
| 54 | * bytes making up the actual contents of the string. The
|
---|
| 55 | * variable-length length consists of bytes whose most-significant bit
|
---|
| 56 | * is 1, if there is another byte and 0 for the last byte. The first
|
---|
| 57 | * byte contains the least significant 7 bits of the length, the
|
---|
| 58 | * second byte contains bits 7-13, and so on. Some examples:
|
---|
| 59 | * - 12 => 0x0c
|
---|
| 60 | * - 123 => 0x7b
|
---|
| 61 | * - 128 => 0x80 0x01
|
---|
| 62 | * - 210 => 0xd2 0x01
|
---|
| 63 | * - 7345 => 0xb1 0x39
|
---|
| 64 | * - 90000 => 0x90 0xbf 0x05
|
---|
| 65 | *
|
---|
[68] | 66 | * \section datatypes Data type codes
|
---|
| 67 | *
|
---|
| 68 | * Each dataref of X-Plane has a certain data type, and some datarefs
|
---|
| 69 | * can represent their values in multiple data types. Because of this
|
---|
| 70 | * ambiguity and the fact that users should know the data type anyway,
|
---|
| 71 | * especially when using a strongly typed language, the type should be
|
---|
| 72 | * sent with the dataref name in commands that refer to one or more
|
---|
| 73 | * datarefs.
|
---|
| 74 | *
|
---|
| 75 | * Each data type is represented as an 8-bit unsigned integer, whose
|
---|
| 76 | * possible values are given in the table below:
|
---|
| 77 | *
|
---|
| 78 | * Data type | Value | Constant name
|
---|
| 79 | * --------- | ----: | -------------
|
---|
| 80 | * 32-bit signed integer | 0x01 | \anchor TYPE_INT TYPE_INT
|
---|
| 81 | * single-precision floating-point value | 0x02 | \anchor TYPE_FLOAT TYPE_FLOAT
|
---|
| 82 | * double-precision floating-point value | 0x03 | \anchor TYPE_DOUBLE TYPE_DOUBLE
|
---|
| 83 | * array of single-precision floating-point values | 0x11 | \anchor TYPE_FLOAT_ARRAY TYPE_FLOAT_ARRAY
|
---|
| 84 | * array of 32-bit signed integers | 0x12 | \anchor TYPE_INT_ARRAY TYPE_INT_ARRAY
|
---|
| 85 | * array of 8-bit unsigned integers (bytes) | 0x13 | \anchor TYPE_BYTE_ARRAY TYPE_BYTE_ARRAY
|
---|
| 86 | *
|
---|
| 87 | * The constant name is the name used in both client APIs to identify
|
---|
| 88 | * the given type.
|
---|
| 89 | *
|
---|
| 90 | * The scalar data types are encoded as in the following table:
|
---|
| 91 | *
|
---|
| 92 | * Data type constant | Encoding
|
---|
| 93 | * ------------------ | --------
|
---|
| 94 | * \ref TYPE_INT | a 32-bit (4-byte) signed integer
|
---|
| 95 | * \ref TYPE_FLOAT | a 32-bit (4-byte) IEEE 754 single-precision floating point value
|
---|
| 96 | * \ref TYPE_DOUBLE | a 64-bit (8-byte) IEEE 754 double-precision floating point value
|
---|
| 97 | *
|
---|
| 98 | * The contents of an array is encoded as a sequence of values of the
|
---|
| 99 | * items' type. It is usually preceded by a 32-bit signed integer
|
---|
| 100 | * denoting the number of items and sometimes also by another 32-bit
|
---|
| 101 | * signed integer denoting the offset into the array.
|
---|
| 102 | *
|
---|
| 103 | * \section resultcodes Result codes
|
---|
| 104 | *
|
---|
| 105 | * The first byte of the reply message to each command is a result
|
---|
| 106 | * code. If the command could be executed properly, it is RESULT_OK
|
---|
| 107 | * followed by the results of the command if any, otherwise it is
|
---|
| 108 | * another code signifying some error. Most error codes are followed
|
---|
| 109 | * by no further data, but \ref RESULT_UNKNOWN_DATAREF may be followed by
|
---|
| 110 | * an index if a multi-dataref request is issued.
|
---|
| 111 | *
|
---|
| 112 | * The table summarizes the error codes:
|
---|
| 113 | *
|
---|
| 114 | * Meaning | Value | Constant name
|
---|
| 115 | * ------- | ----- | -------------
|
---|
| 116 | * Success, everything is OK | 0x00 | \anchor RESULT_OK RESULT_OK
|
---|
| 117 | * Invalid command | 0x01 | \anchor RESULT_INVALID_COMMAND RESULT_INVALID_COMMAND
|
---|
| 118 | * Unknown dataref | 0x02 | \anchor RESULT_UNKNOWN_DATAREF RESULT_UNKNOWN_DATAREF
|
---|
| 119 | * Invalid data type | 0x03 | \anchor RESULT_INVALID_TYPE RESULT_INVALID_TYPE
|
---|
| 120 | * Invalid length | 0x04 | \anchor RESULT_INVALID_LENGTH RESULT_INVALID_LENGTH
|
---|
| 121 | * Invalid offset | 0x05 | \anchor RESULT_INVALID_OFFSET RESULT_INVALID_OFFSET
|
---|
| 122 | * Invalid count | 0x06 | \anchor RESULT_INVALID_COUNT RESULT_INVALID_COUNT
|
---|
| 123 | * Invalid ID | 0x07 | \anchor RESULT_INVALID_ID RESULT_INVALID_ID
|
---|
| 124 | * Invalid duration | 0x08 | \anchor RESULT_INVALID_DURATION RESULT_INVALID_DURATION
|
---|
| 125 | * Other error | 0xff | \anchor RESULT_OTHER_ERROR RESULT_OTHER_ERROR
|
---|
| 126 | *
|
---|
| 127 | * \section limits Limits
|
---|
| 128 | *
|
---|
| 129 | * Certain parameters have limits, which are summarized in the
|
---|
| 130 | * following table:
|
---|
| 131 | *
|
---|
| 132 | * Description | Limit
|
---|
| 133 | * ------- | -----
|
---|
| 134 | * maximal number of array items | 2048
|
---|
| 135 | * maximal number of datarefs in a multi-dataref operation | 1024
|
---|
| 136 | * maximal duration of a message | 5 minutes
|
---|
| 137 | * maximal number of hotkeys that can be registered | 128
|
---|
| 138 | *
|
---|
[67] | 139 | * \section commands Commands
|
---|
| 140 | *
|
---|
| 141 | * This section describes the commands of the protocol with their
|
---|
[68] | 142 | * parameters and the possible replies. Each command is represented by
|
---|
| 143 | * an 8-bit unsigned value, which is the first byte of the
|
---|
| 144 | * message. The table below summarizes the commands with their command
|
---|
| 145 | * byte and constant names:
|
---|
[67] | 146 | *
|
---|
[68] | 147 | * Description | Command byte | Constant Name
|
---|
| 148 | * ----------- | -----------: | -------------
|
---|
| 149 | * \ref command_get_single "Query the value of a single dataref" | 0x01 | \anchor COMMAND_GET_SINGLE COMMAND_GET_SINGLE
|
---|
| 150 | * \ref command_set_single "Set the value of a single dataref" | 0x02 | \anchor COMMAND_SET_SINGLE COMMAND_SET_SINGLE
|
---|
| 151 | * \ref command_get_multi "Query the values of multiple datarefs" | 0x03 | \anchor COMMAND_GET_MULTI COMMAND_GET_MULTI
|
---|
| 152 | * \ref command_set_multi "Set the values of multiple datarefs" | 0x04 | \anchor COMMAND_SET_MULTI COMMAND_SET_MULTI
|
---|
| 153 | * \ref command_register_get_multi "Register a multi-dataref query" | 0x11 | \anchor COMMAND_REGISTER_GET_MULTI COMMAND_REGISTER_GET_MULTI
|
---|
| 154 | * \ref command_unregister_get_multi "Unregister a multi-dataref query" | 0x12 | \anchor COMMAND_UNREGISTER_GET_MULTI COMMAND_UNREGISTER_GET_MULTI
|
---|
| 155 | * \ref command_execute_get_multi "Execute a registered multi-dataref query" | 0x13 | \anchor COMMAND_EXECUTE_GET_MULTI COMMAND_EXECUTE_GET_MULTI
|
---|
| 156 | * \ref command_register_set_multi "Register a multi-dataref update request" | 0x21 | \anchor COMMAND_REGISTER_SET_MULTI COMMAND_REGISTER_SET_MULTI
|
---|
| 157 | * \ref command_unregister_set_multi "Unregister a multi-dataref update request" | 0x22 | \anchor COMMAND_UNREGISTER_SET_MULTI COMMAND_UNREGISTER_SET_MULTI
|
---|
| 158 | * \ref command_execute_set_multi "Execute a registered multi-dataref update request" | 0x23 | \anchor COMMAND_EXECUTE_SET_MULTI COMMAND_EXECUTE_SET_MULTI
|
---|
| 159 | * \ref command_get_versions "Query the versions of X-Plane, XPLM and XPLRA" | 0x31 | \anchor COMMAND_GET_VERSIONS COMMAND_GET_VERSIONS
|
---|
| 160 | * \ref command_reload_plugins "Reload the plugins in X-Plane" | 0x32 | \anchor COMMAND_RELOAD_PLUGINS COMMAND_RELOAD_PLUGINS
|
---|
| 161 | * \ref command_show_message "Show a message in X-Plane's window" | 0x41 | \anchor COMMAND_SHOW_MESSAGE COMMAND_SHOW_MESSAGE
|
---|
| 162 | * \ref command_register_hotkeys "Register hotkeys to be listened to" | 0x51 | \anchor COMMAND_REGISTER_HOTKEYS COMMAND_REGISTER_HOTKEYS
|
---|
| 163 | * \ref command_query_hotkeys "Query the sate of the registered hotkeys" | 0x52 | \anchor COMMAND_QUERY_HOTKEYS COMMAND_QUERY_HOTKEYS
|
---|
| 164 | * \ref command_unregister_hotkeys "Unregister the previously registered hotkets" | 0x53 | \anchor COMMAND_UNREGISTER_HOTKEYS COMMAND_UNREGISTER_HOTKEYS
|
---|
| 165 | *
|
---|
| 166 | * \subsection command_get_single The GET_SINGLE command
|
---|
[67] | 167 | *
|
---|
| 168 | * This command can be used to query the value of a single
|
---|
| 169 | * dataref. Such a data can either be a scalar (integer, float or
|
---|
| 170 | * double) or an array of floats, integers or bytes.
|
---|
| 171 | *
|
---|
[68] | 172 | * The format of the command is the following:
|
---|
| 173 | *
|
---|
| 174 | * Type | Description
|
---|
| 175 | * ---- | ------
|
---|
| 176 | * byte | 0x01 (\ref COMMAND_GET_SINGLE)
|
---|
| 177 | * dataref_query_info | information about the dataref to query
|
---|
| 178 | *
|
---|
| 179 | * \anchor dataref_query_info \c dataref_query_info has the following
|
---|
| 180 | * format for scalar types:
|
---|
| 181 | *
|
---|
| 182 | * Type | Description
|
---|
| 183 | * ---- | ------
|
---|
| 184 | * string | the name of the dataref to query
|
---|
| 185 | * byte | the type of the dataref, one of the \ref datatypes "TYPE_XXX" constants
|
---|
| 186 | *
|
---|
| 187 | * \c dataref_query_info has the following format for array types:
|
---|
| 188 | *
|
---|
| 189 | * Type | Description
|
---|
| 190 | * ---- | ------
|
---|
| 191 | * string | the name of the dataref to query
|
---|
| 192 | * byte | the type of the dataref, one of the \ref datatypes "TYPE_XXX_ARRAY" constants
|
---|
| 193 | * 32-bit signed integer | the number of items to query, -1 to query all items
|
---|
| 194 | * 32-bit signed integer | the offset of the data within the array to query
|
---|
| 195 | *
|
---|
| 196 | * If the command is executed successfully, the reply has the
|
---|
| 197 | * following format for scalar types:
|
---|
| 198 | *
|
---|
| 199 | * Type | Description
|
---|
| 200 | * ---- | ------
|
---|
| 201 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 202 | * dataref_value | the value of the dataref
|
---|
| 203 | *
|
---|
| 204 | * \anchor dataref_value dataref_value is encoded as follows for scalar types:
|
---|
| 205 | *
|
---|
| 206 | * Type | Description
|
---|
| 207 | * ---- | ------
|
---|
| 208 | * scalar type | the value of the dataref
|
---|
| 209 | *
|
---|
| 210 | * dataref_value is encoded as follows for array types:
|
---|
| 211 | *
|
---|
| 212 | * Type | Description
|
---|
| 213 | * ---- | ------
|
---|
| 214 | * 32-bit signed integer | n=the number of items returned
|
---|
| 215 | * n*type of the items | the data items themselves
|
---|
| 216 | *
|
---|
| 217 | * In case of an error:
|
---|
| 218 | *
|
---|
| 219 | * Type | Description
|
---|
| 220 | * ---- | ------
|
---|
| 221 | * byte | the error code
|
---|
| 222 | *
|
---|
| 223 | * The following error codes may be returned:
|
---|
| 224 | *
|
---|
| 225 | * Code | Meaning
|
---|
| 226 | * ---- | -------
|
---|
| 227 | * \ref RESULT_UNKNOWN_DATAREF | the dataref with the given name was not found
|
---|
| 228 | * \ref RESULT_INVALID_TYPE | an unknown type code was given
|
---|
| 229 | * \ref RESULT_INVALID_LENGTH | the length given for an array is too large
|
---|
| 230 | * \ref RESULT_INVALID_OFFSET | the offset given for an array is negative
|
---|
| 231 | *
|
---|
| 232 | * \subsection command_set_single The SET_SINGLE command
|
---|
| 233 | *
|
---|
| 234 | * This command can be used to set the value of a single
|
---|
| 235 | * dataref. Such a data can either be a scalar (integer, float or
|
---|
| 236 | * double) or an array of floats, integers or bytes.
|
---|
| 237 | *
|
---|
| 238 | * The format of the command is the following for scalar values:
|
---|
| 239 | *
|
---|
| 240 | * Type | Description
|
---|
| 241 | * ---- | ------
|
---|
| 242 | * byte | 0x02 (\ref COMMAND_SET_SINGLE)
|
---|
| 243 | * dataref_update_info | information about the dataref to set and the value itself
|
---|
| 244 | *
|
---|
| 245 | * \anchor dataref_update_info \c dataref_update_info has the
|
---|
| 246 | * following format for scalar values:
|
---|
| 247 | *
|
---|
| 248 | * Type | Description
|
---|
| 249 | * ---- | ------
|
---|
| 250 | * string | the name of the dataref to set
|
---|
| 251 | * byte | the type of the dataref, one of the \ref datatypes "TYPE_XXX" constants
|
---|
| 252 | * dataref's type | the value to set
|
---|
| 253 | *
|
---|
| 254 | * \c dataref_update_info has the following format for array values:
|
---|
| 255 | *
|
---|
| 256 | * Type | Description
|
---|
| 257 | * ---- | ------
|
---|
| 258 | * string | the name of the dataref to set
|
---|
| 259 | * byte | the type of the dataref, one of the \ref datatypes "TYPE_XXX_ARRAY" constants
|
---|
| 260 | * 32-bit signed integer | n=the number of items to set
|
---|
| 261 | * 32-bit signed integer | the offset from which to set the values
|
---|
| 262 | * n*type of the items | the actual values of the array
|
---|
| 263 | *
|
---|
| 264 | * If the command is executed successfully, the reply has the
|
---|
| 265 | * following format for scalar types:
|
---|
| 266 | *
|
---|
| 267 | * Type | Description
|
---|
| 268 | * ---- | ------
|
---|
| 269 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 270 | *
|
---|
| 271 | * If an error was encountered, the reply has the following format:
|
---|
| 272 | *
|
---|
| 273 | * Type | Description
|
---|
| 274 | * ---- | ------
|
---|
| 275 | * byte | the error code
|
---|
| 276 | *
|
---|
| 277 | * The following error codes may be returned:
|
---|
| 278 | *
|
---|
| 279 | * Code | Meaning
|
---|
| 280 | * ---- | -------
|
---|
| 281 | * \ref RESULT_UNKNOWN_DATAREF | the dataref with the given name was not found
|
---|
| 282 | * \ref RESULT_INVALID_TYPE | an unknown type code was given
|
---|
| 283 | * \ref RESULT_INVALID_LENGTH | the length given for an array is too large or not positive
|
---|
| 284 | * \ref RESULT_INVALID_OFFSET | the offset given for an array is negative
|
---|
| 285 | *
|
---|
| 286 | * \subsection command_get_multi The GET_MULTI command
|
---|
| 287 | *
|
---|
| 288 | * This command can be used to query the values of several datarefs in
|
---|
| 289 | * one call. It is encoded as follows:
|
---|
| 290 | *
|
---|
| 291 | * Type | Description
|
---|
| 292 | * ---- | ------
|
---|
| 293 | * byte | 0x03 (\ref COMMAND_GET_MULTI)
|
---|
| 294 | * 32-bit unsigned integer | n=the number of datarefs to query
|
---|
| 295 | * n*\ref dataref_query_info | information about the datarefs to query.
|
---|
| 296 | *
|
---|
| 297 | * In case of success, the reply is the following:
|
---|
| 298 | *
|
---|
| 299 | * Type | Description
|
---|
| 300 | * ---- | ------
|
---|
| 301 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 302 | * n*\ref dataref_value | the values of the datarefs
|
---|
[67] | 303 | *
|
---|
[68] | 304 | * If an error was encountered, the reply has the following format:
|
---|
| 305 | *
|
---|
| 306 | * Type | Description
|
---|
| 307 | * ---- | ------
|
---|
| 308 | * byte | the error code
|
---|
| 309 | * 32-bit unsigned integer | if the error code is \ref RESULT_UNKNOWN_DATAREF : the 0-based index of the first dataref that was not found
|
---|
| 310 | *
|
---|
| 311 | * The following error codes may be returned:
|
---|
| 312 | *
|
---|
| 313 | * Code | Meaning
|
---|
| 314 | * ---- | -------
|
---|
| 315 | * \ref RESULT_UNKNOWN_DATAREF | the dataref with the given name was not found
|
---|
| 316 | * \ref RESULT_INVALID_TYPE | an unknown type code was given
|
---|
| 317 | * \ref RESULT_INVALID_LENGTH | the length given for an array is too large
|
---|
| 318 | * \ref RESULT_INVALID_OFFSET | the offset given for an array is negative
|
---|
| 319 | * \ref RESULT_INVALID_COUNT | the number of datarefs was either 0 or too large
|
---|
| 320 | *
|
---|
| 321 | * \subsection command_set_multi The SET_MULTI command
|
---|
| 322 | *
|
---|
| 323 | * This command can be used to set the values of several datarefs in
|
---|
| 324 | * one call. It is encoded as follows:
|
---|
| 325 | *
|
---|
| 326 | * Type | Description
|
---|
| 327 | * ---- | ------
|
---|
| 328 | * byte | 0x04 (\ref COMMAND_SET_MULTI)
|
---|
| 329 | * 32-bit unsigned integer | n=the number of datarefs to set
|
---|
| 330 | * n*\ref dataref_update_info | information about the datarefs to set
|
---|
| 331 | *
|
---|
| 332 | * In case of success, the reply is the following:
|
---|
| 333 | *
|
---|
| 334 | * Type | Description
|
---|
| 335 | * ---- | ------
|
---|
| 336 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 337 | *
|
---|
| 338 | * If an error was encountered, the reply has the following format:
|
---|
| 339 | *
|
---|
| 340 | * Type | Description
|
---|
| 341 | * ---- | ------
|
---|
| 342 | * byte | the error code
|
---|
| 343 | * 32-bit unsigned integer | if the error code is \ref RESULT_UNKNOWN_DATAREF : the 0-based index of the first dataref that was not found
|
---|
| 344 | *
|
---|
| 345 | * The following error codes may be returned:
|
---|
| 346 | *
|
---|
| 347 | * Code | Meaning
|
---|
| 348 | * ---- | -------
|
---|
| 349 | * \ref RESULT_UNKNOWN_DATAREF | the dataref with the given name was not found
|
---|
| 350 | * \ref RESULT_INVALID_TYPE | an unknown type code was given
|
---|
| 351 | * \ref RESULT_INVALID_LENGTH | the length given for an array is too large or not positive
|
---|
| 352 | * \ref RESULT_INVALID_OFFSET | the offset given for an array is negative
|
---|
| 353 | * \ref RESULT_INVALID_COUNT | the number of datarefs was either 0 or too large
|
---|
| 354 | *
|
---|
| 355 | * \subsection command_register_get_multi The REGISTER_GET_MULTI command
|
---|
| 356 | *
|
---|
| 357 | * This command can be used to register a multi-dataref query. A
|
---|
| 358 | * multi-dataref query is a list of datarefs that are queried
|
---|
| 359 | * together. The query will be associated with an identifier that can
|
---|
| 360 | * be used later to refer to the query when actually querying the
|
---|
| 361 | * values or when unregistering it. The identifier is unique only for
|
---|
| 362 | * the client connection and among the multi-dataref queries.
|
---|
| 363 | *
|
---|
| 364 | * Type | Description
|
---|
| 365 | * ---- | ------
|
---|
| 366 | * byte | 0x11 (\ref COMMAND_REGISTER_GET_MULTI)
|
---|
| 367 | * 32-bit unsigned integer | n=the number of datarefs to query
|
---|
| 368 | * n*\ref dataref_query_info | information about the datarefs to query.
|
---|
[67] | 369 | *
|
---|
[68] | 370 | * In case of success, the reply is the following:
|
---|
| 371 | *
|
---|
| 372 | * Type | Description
|
---|
| 373 | * ---- | ------
|
---|
| 374 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 375 | * 32-bit unsigned integer | the identifier of the registered query
|
---|
| 376 | *
|
---|
| 377 | * If an error was encountered, the reply has the following format:
|
---|
| 378 | *
|
---|
| 379 | * Type | Description
|
---|
| 380 | * ---- | ------
|
---|
| 381 | * byte | the error code
|
---|
| 382 | *
|
---|
| 383 | * The following error codes may be returned:
|
---|
| 384 | *
|
---|
| 385 | * Code | Meaning
|
---|
| 386 | * ---- | -------
|
---|
| 387 | * \ref RESULT_INVALID_TYPE | an unknown type code was given
|
---|
| 388 | * \ref RESULT_INVALID_LENGTH | the length given for an array is too large
|
---|
| 389 | * \ref RESULT_INVALID_OFFSET | the offset given for an array is negative
|
---|
| 390 | * \ref RESULT_INVALID_COUNT | the number of datarefs was either 0 or too large
|
---|
| 391 | *
|
---|
| 392 | * \subsection command_unregister_get_multi The UNREGISTER_GET_MULTI command
|
---|
| 393 | *
|
---|
| 394 | * This command can be used to unregister a previously registered
|
---|
| 395 | * multi-dataref query.
|
---|
| 396 | *
|
---|
| 397 | * Type | Description
|
---|
| 398 | * ---- | ------
|
---|
| 399 | * byte | 0x12 (\ref COMMAND_UNREGISTER_GET_MULTI)
|
---|
| 400 | * 32-bit unsigned integer | the identifier of the query to unregister
|
---|
| 401 | *
|
---|
| 402 | * In case of success, the reply is the following:
|
---|
| 403 | *
|
---|
| 404 | * Type | Description
|
---|
| 405 | * ---- | ------
|
---|
| 406 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 407 | *
|
---|
| 408 | * If an error was encountered, the reply has the following format:
|
---|
| 409 | *
|
---|
| 410 | * Type | Description
|
---|
| 411 | * ---- | ------
|
---|
| 412 | * byte | the error code
|
---|
| 413 | *
|
---|
| 414 | * The following error codes may be returned:
|
---|
| 415 | *
|
---|
| 416 | * Code | Meaning
|
---|
| 417 | * ---- | -------
|
---|
| 418 | * \ref RESULT_INVALID_ID | an identifier was given that is not associated with any registered query
|
---|
| 419 | *
|
---|
| 420 | * \subsection command_execute_get_multi The EXECUTE_GET_MULTI command
|
---|
| 421 | *
|
---|
| 422 | * This command can be used to execute a previously registered
|
---|
| 423 | * multi-dataref query.
|
---|
| 424 | *
|
---|
| 425 | * Type | Description
|
---|
| 426 | * ---- | ------
|
---|
| 427 | * byte | 0x13 (\ref COMMAND_EXECUTE_GET_MULTI)
|
---|
| 428 | * 32-bit unsigned integer | the identifier of the query to execute
|
---|
| 429 | *
|
---|
| 430 | * In case of success, the reply is the following:
|
---|
| 431 | *
|
---|
| 432 | * Type | Description
|
---|
| 433 | * ---- | ------
|
---|
| 434 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 435 | * n*\ref dataref_value | the values of the datarefs, n is the number of them
|
---|
[67] | 436 | *
|
---|
[68] | 437 | * If an error was encountered, the reply has the following format:
|
---|
| 438 | *
|
---|
| 439 | * Type | Description
|
---|
| 440 | * ---- | ------
|
---|
| 441 | * byte | the error code
|
---|
| 442 | * 32-bit unsigned integer | if the error code is \ref RESULT_UNKNOWN_DATAREF : the 0-based index of the first dataref that was not found
|
---|
| 443 | *
|
---|
| 444 | * The following error codes may be returned:
|
---|
| 445 | *
|
---|
| 446 | * Code | Meaning
|
---|
| 447 | * ---- | -------
|
---|
| 448 | * \ref RESULT_UNKNOWN_DATAREF | the dataref with the given name was not found
|
---|
| 449 | * \ref RESULT_INVALID_ID | an identifier was given that is not associated with any registered query
|
---|
| 450 | *
|
---|
| 451 | * \subsection command_register_set_multi The REGISTER_SET_MULTI command
|
---|
| 452 | *
|
---|
| 453 | * This command can be used to register a multi-dataref update. A
|
---|
| 454 | * multi-dataref update is a list of datarefs that are updated
|
---|
| 455 | * together with values supplied for each update. The update will be
|
---|
| 456 | * associated with an identifier that can be used later to refer to
|
---|
| 457 | * the update when actually updating the values or when unregistering
|
---|
| 458 | * it. The identifier is unique only for the client connection and
|
---|
| 459 | * among the multi-dataref updates.
|
---|
| 460 | *
|
---|
| 461 | * Type | Description
|
---|
| 462 | * ---- | ------
|
---|
| 463 | * byte | 0x21 (\ref COMMAND_REGISTER_SET_MULTI)
|
---|
| 464 | * 32-bit unsigned integer | n=the number of datarefs to query
|
---|
| 465 | * n*\ref dataref_query_info | information about the datarefs to update (this \a is \ref dataref_query_info, because the format is the same, since we don't supply any values)
|
---|
| 466 | *
|
---|
| 467 | * In case of success, the reply is the following:
|
---|
| 468 | *
|
---|
| 469 | * Type | Description
|
---|
| 470 | * ---- | ------
|
---|
| 471 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 472 | * 32-bit unsigned integer | the identifier of the registered query
|
---|
| 473 | *
|
---|
| 474 | * If an error was encountered, the reply has the following format:
|
---|
| 475 | *
|
---|
| 476 | * Type | Description
|
---|
| 477 | * ---- | ------
|
---|
| 478 | * byte | the error code
|
---|
| 479 | *
|
---|
| 480 | * The following error codes may be returned:
|
---|
| 481 | *
|
---|
| 482 | * Code | Meaning
|
---|
| 483 | * ---- | -------
|
---|
| 484 | * \ref RESULT_INVALID_TYPE | an unknown type code was given
|
---|
| 485 | * \ref RESULT_INVALID_LENGTH | the length given for an array is too large or not positive
|
---|
| 486 | * \ref RESULT_INVALID_OFFSET | the offset given for an array is negative
|
---|
| 487 | * \ref RESULT_INVALID_COUNT | the number of datarefs was either 0 or too large
|
---|
| 488 | *
|
---|
| 489 | * \subsection command_unregister_set_multi The UNREGISTER_GET_MULTI command
|
---|
| 490 | *
|
---|
| 491 | * This command can be used to unregister a previously registered
|
---|
| 492 | * multi-dataref update.
|
---|
| 493 | *
|
---|
| 494 | * Type | Description
|
---|
| 495 | * ---- | ------
|
---|
| 496 | * byte | 0x22 (\ref COMMAND_UNREGISTER_SET_MULTI)
|
---|
| 497 | * 32-bit unsigned integer | the identifier of the update to unregister
|
---|
| 498 | *
|
---|
| 499 | * In case of success, the reply is the following:
|
---|
| 500 | *
|
---|
| 501 | * Type | Description
|
---|
| 502 | * ---- | ------
|
---|
| 503 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 504 | *
|
---|
| 505 | * If an error was encountered, the reply has the following format:
|
---|
| 506 | *
|
---|
| 507 | * Type | Description
|
---|
| 508 | * ---- | ------
|
---|
| 509 | * byte | the error code
|
---|
| 510 | *
|
---|
| 511 | * The following error codes may be returned:
|
---|
| 512 | *
|
---|
| 513 | * Code | Meaning
|
---|
| 514 | * ---- | -------
|
---|
| 515 | * \ref RESULT_INVALID_ID | an identifier was given that is not associated with any registered update
|
---|
| 516 | *
|
---|
| 517 | * \subsection command_execute_set_multi The EXECUTE_SET_MULTI command
|
---|
| 518 | *
|
---|
| 519 | * This command can be used to execute a previously registered
|
---|
| 520 | * multi-dataref update.
|
---|
| 521 | *
|
---|
| 522 | * Type | Description
|
---|
| 523 | * ---- | ------
|
---|
| 524 | * byte | 0x23 (\ref COMMAND_EXECUTE_SET_MULTI)
|
---|
| 525 | * 32-bit unsigned integer | the identifier of the update to execute
|
---|
| 526 | * n*\ref dataref_value | the values
|
---|
| 527 | *
|
---|
| 528 | * In case of success, the reply is the following:
|
---|
| 529 | *
|
---|
| 530 | * Type | Description
|
---|
| 531 | * ---- | ------
|
---|
| 532 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 533 | *
|
---|
| 534 | * If an error was encountered, the reply has the following format:
|
---|
| 535 | *
|
---|
| 536 | * Type | Description
|
---|
| 537 | * ---- | ------
|
---|
| 538 | * byte | the error code
|
---|
| 539 | * 32-bit unsigned integer | if the error code is \ref RESULT_UNKNOWN_DATAREF : the 0-based index of the first dataref that was not found
|
---|
| 540 | *
|
---|
| 541 | * The following error codes may be returned:
|
---|
| 542 | *
|
---|
| 543 | * Code | Meaning
|
---|
| 544 | * ---- | -------
|
---|
| 545 | * \ref RESULT_UNKNOWN_DATAREF | the dataref with the given name was not found
|
---|
| 546 | * \ref RESULT_INVALID_ID | an identifier was given that is not associated with any registered query
|
---|
| 547 | *
|
---|
| 548 | * \subsection command_get_versions The GET_VERSIONS command
|
---|
| 549 | *
|
---|
| 550 | * This command can be used to query the versions of X-Plane, XPLM and
|
---|
| 551 | * XPLRA itself.
|
---|
| 552 | *
|
---|
| 553 | * Type | Description
|
---|
| 554 | * ---- | ------
|
---|
| 555 | * byte | 0x31 (\ref COMMAND_GET_VERSIONS)
|
---|
| 556 | *
|
---|
| 557 | * The reply is encoded the following way (it shall never fail):
|
---|
| 558 | *
|
---|
| 559 | * Type | Description
|
---|
| 560 | * ---- | ------
|
---|
| 561 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 562 | * 32-bit signed integer | the version of X-Plane. For 10.20r1 it is 10201.
|
---|
| 563 | * 32-bit signed integer | the version of XPLM. For 2.10 it is 210.
|
---|
| 564 | * 32-bit signed integer | the version of XPLRA. For 0.1 it is 10.
|
---|
| 565 | *
|
---|
| 566 | * \subsection command_reload_plugins The RELOAD_PLUGINS command
|
---|
[67] | 567 | *
|
---|
[68] | 568 | * This command can be used to reload the plugins in X-Plane. This is
|
---|
| 569 | * useful for debugging.
|
---|
| 570 | *
|
---|
| 571 | * Type | Description
|
---|
| 572 | * ---- | ------
|
---|
| 573 | * byte | 0x32 (\ref COMMAND_RELOAD_PLUGINS)
|
---|
| 574 | *
|
---|
| 575 | * The reply is encoded the following way (it shall never fail):
|
---|
| 576 | *
|
---|
| 577 | * Type | Description
|
---|
| 578 | * ---- | ------
|
---|
| 579 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 580 | *
|
---|
| 581 | * \subsection command_get_versions The GET_VERSIONS command
|
---|
| 582 | *
|
---|
| 583 | * This command can be used to query the versions of X-Plane, XPLM and
|
---|
| 584 | * XPLRA itself.
|
---|
| 585 | *
|
---|
| 586 | * Type | Description
|
---|
| 587 | * ---- | ------
|
---|
| 588 | * byte | 0x31 (\ref COMMAND_GET_VERSIONS)
|
---|
| 589 | *
|
---|
| 590 | * The reply is encoded the following way (it shall never fail):
|
---|
| 591 | *
|
---|
| 592 | * Type | Description
|
---|
| 593 | * ---- | ------
|
---|
| 594 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 595 | * 32-bit signed integer | the version of X-Plane. For 10.20r1 it is 10201.
|
---|
| 596 | * 32-bit signed integer | the version of XPLM. For 2.10 it is 210.
|
---|
| 597 | * 32-bit signed integer | the version of XPLRA. For 0.1 it is 10.
|
---|
| 598 | *
|
---|
| 599 | * \subsection command_show_message The SHOW_MESSAGE command
|
---|
| 600 | *
|
---|
| 601 | * This command can be used to show a message in a window to the
|
---|
| 602 | * user. The window is a single line window around the top 1/3rd of
|
---|
| 603 | * the screen. It can be moved and resized by mouse actions. If a
|
---|
| 604 | * message is being displayed when this command is issued, that
|
---|
| 605 | * message will be replaced by the new one.
|
---|
| 606 | *
|
---|
| 607 | * Type | Description
|
---|
| 608 | * ---- | ------
|
---|
| 609 | * byte | 0x41 (\ref COMMAND_SHOW_MESSAGE)
|
---|
| 610 | * string | the message to show
|
---|
| 611 | * float | the duration of the message in seconds
|
---|
| 612 | *
|
---|
| 613 | * If successful, the reply is the following:
|
---|
| 614 | *
|
---|
| 615 | * Type | Description
|
---|
| 616 | * ---- | ------
|
---|
| 617 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 618 | *
|
---|
| 619 | * If an error was encountered, the reply has the following format:
|
---|
| 620 | *
|
---|
| 621 | * Type | Description
|
---|
| 622 | * ---- | ------
|
---|
| 623 | * byte | the error code
|
---|
| 624 | *
|
---|
| 625 | * The following error codes may be returned:
|
---|
| 626 | *
|
---|
| 627 | * Code | Meaning
|
---|
| 628 | * ---- | -------
|
---|
| 629 | * \ref RESULT_INVALID_DURATION | the duration is too large
|
---|
| 630 | *
|
---|
| 631 | * \subsection command_register_hotkeys The REGISTER_HOTKEYS command
|
---|
| 632 | *
|
---|
| 633 | * This command can be used to register a set of hotkeys to be
|
---|
| 634 | * monitored. If any other hotkeys have been registered by the current
|
---|
| 635 | * client previously, they are forgotten.
|
---|
| 636 | *
|
---|
| 637 | * Type | Description
|
---|
| 638 | * ---- | ------
|
---|
| 639 | * byte | 0x51 (\ref COMMAND_REGISTER_HOTKEYS)
|
---|
| 640 | * 32-bit unsigned integer | n=the number of the hotkeys
|
---|
| 641 | * n * 16-bit unsigned integer | the codes of the hotkeys
|
---|
| 642 | *
|
---|
| 643 | * The lower-byte of a hotkey code is the same as the X-Plane virtual
|
---|
| 644 | * key code. The upper byte is a logical OR of zero or more modifiers:
|
---|
| 645 | *
|
---|
| 646 | * Value | Description | Constant name
|
---|
| 647 | * --: | --- | ---
|
---|
| 648 | * 0x0100 | Shift modifier | HOTKEY_MODIFIER_SHIFT
|
---|
| 649 | * 0x0200 | Control modifier | HOTKEY_MODIFIER_CONTROL
|
---|
| 650 | *
|
---|
| 651 | * If successful, the reply is the following:
|
---|
| 652 | *
|
---|
| 653 | * Type | Description
|
---|
| 654 | * ---- | ------
|
---|
| 655 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 656 | *
|
---|
| 657 | * If an error was encountered, the reply has the following format:
|
---|
| 658 | *
|
---|
| 659 | * Type | Description
|
---|
| 660 | * ---- | ------
|
---|
| 661 | * byte | the error code
|
---|
| 662 | *
|
---|
| 663 | * The following error codes may be returned:
|
---|
| 664 | *
|
---|
| 665 | * Code | Meaning
|
---|
| 666 | * ---- | -------
|
---|
| 667 | * \ref RESULT_INVALID_LENGTH | too many hotkeys were given
|
---|
| 668 | *
|
---|
| 669 | * \subsection command_query_hotkeys The QUERY_HOTKEYS command
|
---|
| 670 | *
|
---|
| 671 | * This command can be used to query which hotkeys have been pressed
|
---|
| 672 | * since the last query.
|
---|
| 673 | *
|
---|
| 674 | * Type | Description
|
---|
| 675 | * ---- | ------
|
---|
| 676 | * byte | 0x52 (\ref COMMAND_QUERY_HOTKEYS)
|
---|
| 677 | *
|
---|
| 678 | * The reply is the following:
|
---|
| 679 | *
|
---|
| 680 | * Type | Description
|
---|
| 681 | * ---- | ------
|
---|
| 682 | * byte | 0x00 (\ref RESULT_OK)
|
---|
| 683 | * 32-bit unsigned integer | n = the number of hotkeys registered
|
---|
| 684 | * n * 8-bit unsigned integer | each byte is 0 or 1 depending whether the corresponding hotkeys was pressed or not. The value at index i corresponds to the hotkey code at index i in the array passed with \ref command_register_hotkeys "COMMAND_REGISTER_HOTKEYS"
|
---|
| 685 | *
|
---|
| 686 | * \subsection command_unregister_hotkeys The UNREGISTER_HOTKEYS command
|
---|
| 687 | *
|
---|
| 688 | * This command can be used to unregister a previously registered set
|
---|
| 689 | * of hotkeys to be monitored.
|
---|
| 690 | *
|
---|
| 691 | * Type | Description
|
---|
| 692 | * ---- | ------
|
---|
| 693 | * byte | 0x53 (\ref COMMAND_UNREGISTER_HOTKEYS)
|
---|
| 694 | *
|
---|
| 695 | * The reply is the following:
|
---|
| 696 | *
|
---|
| 697 | * Type | Description
|
---|
| 698 | * ---- | ------
|
---|
| 699 | * byte | 0x00 (\ref RESULT_OK)
|
---|
[67] | 700 | */
|
---|
[70] | 701 | /*! \page cppapi C/C++ Client API
|
---|
[69] | 702 | *
|
---|
[70] | 703 | * The C++ client API's central class is \ref
|
---|
[69] | 704 | * hu::varadiistvan::xplra::XPlane. To communicate with the XPLRA
|
---|
| 705 | * plugin in X-Plane, create an instance of it. This, however, does
|
---|
| 706 | * not establish the connection yet. To actually connect, call the
|
---|
| 707 | * \ref hu::varadiistvan::xplra::XPlane::connect "connect" member
|
---|
| 708 | * function. If the connection is established, it returns otherwise it
|
---|
| 709 | * throws a \ref hu::varadiistvan::xplra::IOException.
|
---|
| 710 | *
|
---|
| 711 | * \c IOException is part of the exception hierarchy of the client
|
---|
[70] | 712 | * API. The hierarchy begins with \ref
|
---|
[69] | 713 | * hu::varadiistvan::xplra::Exception. The \c what function is
|
---|
| 714 | * implemented for all exception classes, so you can always get a
|
---|
| 715 | * string representation of the problem for logging or to display
|
---|
| 716 | * it. \c IOException further makes available an error code, which is
|
---|
| 717 | * the standard operating system-specific fault code of the I/O error
|
---|
| 718 | * that occured.
|
---|
| 719 | *
|
---|
| 720 | * \ref hu::varadiistvan::xplra::ProtocolException is thrown for
|
---|
| 721 | * errors returned by the plugin usually due to some incorrect
|
---|
| 722 | * parameter. See also the \ref proto description for the meaning
|
---|
| 723 | * and applicability of these error codes.
|
---|
| 724 | *
|
---|
| 725 | * The \c XPlane object can be reused in the sense, that after you
|
---|
| 726 | * have made a connection, you can disconnect and then connect
|
---|
| 727 | * again. This may be useful, if X-Plane crashes for some reason, and
|
---|
| 728 | * you can then reconnect if the user has restarted it.
|
---|
| 729 | *
|
---|
| 730 | * The \ref hu::varadiistvan::xplra::XPlane::createMultiGetter
|
---|
| 731 | * "createMultiGetter" function can be used to create a multi-dataref
|
---|
| 732 | * query object. It returns an instance of
|
---|
| 733 | * \ref hu::varadiistvan::xplra::MultiGetter "MultiGetter", which can
|
---|
| 734 | * be used to store a number of datarefs and then execute a
|
---|
| 735 | * multi-dataref query for those datarefs. Before execution, the query
|
---|
| 736 | * can be \ref hu::varadiistvan::xplra::MultiBuffer::registerInXPlane
|
---|
| 737 | * "registered" in the plugin, so that the client does not have to send
|
---|
| 738 | * all the dataref information whenever the query is executed.
|
---|
| 739 | *
|
---|
| 740 | * The \c XPlane object knows about any multi-dataref query objects.
|
---|
| 741 | * Therefore if you register such a multi-dataref query, and then the
|
---|
| 742 | * connection breaks, and then you reconnect, the query will-be
|
---|
| 743 | * re-registered too, i.e. you don't have to do it yourself.
|
---|
| 744 | *
|
---|
| 745 | * Similarly, the \ref hu::varadiistvan::xplra::XPlane::createMultiSetter
|
---|
| 746 | * "createMultiSetter" function can be used to create a multi-dataref
|
---|
| 747 | * update object. They are handled the same way by \c XPlane as the
|
---|
| 748 | * query objects when it comes to registration and re-registration.
|
---|
| 749 | *
|
---|
| 750 | * The other functions of \c XPlane are mostly self-explanatory: they
|
---|
| 751 | * perform the operations defined by the protocol. Several operations
|
---|
| 752 | * have more than one corresponding functions with different
|
---|
| 753 | * parameters for convenience.
|
---|
[70] | 754 | *
|
---|
| 755 | * The \ref src/client/c/hu/varadiistvan/xplra/xplra.h "C API" is
|
---|
| 756 | * a wrapper over the C++ one, so its logic is essentially the
|
---|
| 757 | * same. To connect to X-Plane, call \ref xplra_connect. It returns a
|
---|
| 758 | * non-negative handle, which can be used to refer to the connection
|
---|
| 759 | * (i.e. the underlying \c XPlane object) in the other functions.
|
---|
| 760 | *
|
---|
| 761 | * In case of error, it, and most other functions of the C returns
|
---|
| 762 | * -1. To check what the last error was, call \ref
|
---|
| 763 | * xplra_get_last_error or \ref xplra_get_last_error_string.
|
---|
| 764 | *
|
---|
| 765 | * You can create multi-dataref buffers with C API as well with
|
---|
| 766 | * \ref xplra_multi_create_getter and \ref
|
---|
| 767 | * xplra_multi_create_setter. These return a buffer ID on success, and
|
---|
| 768 | * you should use that buffer ID later on to manipulate the buffer.
|
---|
[69] | 769 | */
|
---|
[70] | 770 | /*! \page pythonapi Python Client API
|
---|
[69] | 771 | *
|
---|
| 772 | */
|
---|