About Packets
Packet Structure
The ANPP packet structure and the header format are shown in the tables below. Example source code is provided in multiple languages via the SDK, available from the GNSS Compass product page of the Advanced Navigation website.
Header | ||||
---|---|---|---|---|
Header LRC | Packet ID | Packet Length | CRC16 | Packet Data |
ANPP Packet Structure
Field # | Bytes Offset | Data Type | Size | Description |
---|---|---|---|---|
1 | 0 | u8 | 1 | Header LRC |
2 | 1 | u8 | 1 | Packet ID |
3 | 2 | u8 | 1 | Packet Length |
4 | 3 | u16 | 2 | CRC |
ANPP Header Format
Header LRC
The header LRC (Longitudinal Redundancy Check) provides error checking on the packet header. It also allows the decoder to find the start of a packet by scanning for a valid LRC. Only the lower 8 bits of the calculation below are provided in the LRC field of the packet header. The LRC can be found using the following:
Packet ID
The packet ID is used to distinguish the contents of the packet. Packet IDs range from 0 to 255. See Advanced Navigation Packet Protocol.
System packets have packet IDs in the range 0 to 19. These packets are implemented the same by every device using ANPP.
State packets are packets that contain data that changes with time, i.e. temperature. State packets can be set to output at a certain rate. State packets are packet IDs in the range 20 to 179.
Configuration packets are used for reading and writing device configuration. Configuration packets are packet IDs in the range 180 to 255.
Packet Length
The packet length denotes the length of the packet data, i.e. from byte index 5 onwards inclusive. Packet length has a range of 0 – 255.
CRC
The CRC is a CRC16-CCITT. The starting value is 0xFFFF. The CRC covers only the packet data.
Packet Requests
Any of the state and configuration packets can be requested at any time using the Request Packet.
Packet Acknowledgement
When configuration packets are sent to GNSS Compass, it will reply with an acknowledgement packet that indicates whether the configuration change was successful or not. See Acknowledge Packet.
External data packets will also generate negative acknowledgement packets if there is a problem with the packet. Positive acknowledgements will not be sent. See External Data for a list of External Data Packets.
Packet Rates
The packet rates can be configured either using the web UI, or GNSS Compass Manager or through the Packets Period Packet. By default GNSS Compass is configured to output the System State Packet at 20 Hz and the Raw Sensors Packet at 20 Hz. When configuring packet rates it is essential to ensure the baud rate is capable of handling the data throughput. This can be calculated using the rate and packet size. The packet size is calculated by adding the packet overhead to the packet length; the packet overhead is a fixed value of 5. For example to output the system state packet at 50Hz the calculation would be:
Data throughput = (100 (packet length) + 5 (fixed packet overhead)) * 50 (rate)
Data throughput = 5250 bytes per second
Minimum baud rate = data throughput x 10 bits per byte (including framing bits) x 1.1 (10% margin) = 57750 Baud
Closest standard baud rate = 115200 Baud
When multiple packets are set to output at the same rate, the order the packets output is from lowest ID to highest ID.
Packet Timing
Packets are output in order of packet ID from lowest ID to highest ID and all packets that are output in one sequence have their data matched to the same time of validity. The time of validity can be found in either the System State Packet, the Unix Time Packet or the Formatted Time Packet. For example if the Unix Time Packet, Status Packet and NED Velocity Packet packet were all set to output at 10 Hz, at each 0.1 second period the three packets would output consecutively by order of packet ID with all data synchronised between them and the Unix Time Packet providing the time of validity for the other two packets.