The first byte represents the which of 3 message types are being used:
- 0x00 = Timestamp (start of a new cycle)
- 0x01 = Key (defines string value for a key ID)
- 0x02 = Field (value of a single field)
Following the first byte, a timestamp message consists of a single double (8 bytes) representing the timestamp in seconds. This message marks the start of a new cycle and the timestamp should be associated with subsequent fields.
Each human readable string key (e.g. "/DriveTrain/LeftPositionRadians") is represented by a key ID to reduce the space required to encode the data from each cycle. Key IDs are shorts (2 bytes) which count up from 0. Each key message contains the following information:
- Key ID (short, 2 bytes)
- Length of string key (short, 2 bytes)
- String key (UTF-8 encoded)
Field messages represent a change to a single value. If a key is not provided for a given cycle, its type will be become null. The structure of these messages begins with the following information:
- Key ID (short, 2 bytes)
- Value type (1 byte)
The possible value types are listed below along with the format of the value. Null (0x00) does not include more information.
- Field value (0x00 or 0x01, 1 byte)
- Length of array (short, 2 bytes)
- Contents of array (series of 0x00 or 0x01, 1 byte each)
- Field value (integer, 4 bytes)
- Length of array (short, 2 bytes)
- Contents of array (integers, 4 bytes each)
- Field value (double, 8 bytes)
- Length of array (short, 2 bytes)
- Contents of array (doubles, 8 bytes each)
- Length of string (short, 2 bytes)
- Field value (UTF-8 encoded)
- Length of array (short, 2 bytes)
- Contents of array (same format as single string)
- Field value (1 byte)
- Length of array (short, 2 bytes)
- Contents of array (series of bytes)