The first byte represents the log format revision. The decoding device should always check whether it supports the specified revision before continuing. Below is a list of possible revisions:
- R1 = Supported by AdvantageKit v0.0.1-v1.8.1 and v2.2.0-v3.1.1. Uses a predefined set of field types.
- R2 = Supported by AdvantageKit v3.2.0 and newer. Uses string names for field types.
All values are stored in big endian order.
The next 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 byte for message type, 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) that count up from 0. Each key message contains the following information:
- Key ID (short, 2 bytes)
- Number of bytes in string (short, 2 bytes)
- String key (UTF-8 encoded)
- Number of bytes in string (short, 2 bytes) - Only if RLOG R2
- String type (UTF-8 encoded) - Only if RLOG R2
Field messages represent a change to a single value. The structure of these messages begins with the following information:
- Key ID (short, 2 bytes)
- Value type (1 byte) - Only if RLOG R1
- Value length (short, 2 bytes) - Only if RLOG R2
For RLOG R2, the value can follow any format. By default, use the WPILOG-specified data types.
For RLOG R1, 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)
- Number of bytes in 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)
When sending log data over a network, the same format is used. Each cycle is preceded by a single integer (4 bytes) containing the number of bytes in the cycle. This allows the client to easily determine when a cycle can be decoded.
For efficiency, the server can encode the same data for every client after the first cycle. When a new client connects, the server should send:
- The log format revision (described above).
- Definitions of each pre-existing key ID.
- Every value from the most recent cycle, regardless of whether any changes occurred.
This information allows the new device to "catch up" and decode the log the same as any older client.