As per the protocol specification
In general, a checksum is a verification metric, used to help ensure a message has arrived without errors/modification.
Similarly to the documented negotiation example, if you wish to request a ping1d_distance_simple
(1211) message from the sonar, you can send a general_request
(6) to do so. The components for that would be
Value (HEX) | Value (decimal) | Type | Name | Notes | Send Bytes |
---|---|---|---|---|---|
0x42 | 66 | u8 | start1 | ASCII ‘B’ | 0x42 |
0x52 | 82 | u8 | start2 | ASCII ‘R’ | 0x52 |
0x0002 | 2 | u16 | payload_length | 0x02, 0x00 | |
0x0006 | 6 | u16 | message_id | general_request | 0x06, 0x00 |
0x00 | 0 | u8 | src_device_id | 0x00 | |
0x00 | 0 | u8 | dst_device_id | 0x00 | |
0x04BB | 1211 | u8[2] | payload | requested_id | 0xBB 0x04 |
0x015B | 347 | u16 | checksum | 0x5B 0x01 |
Note that the checksum is the sum of individual bytes, so for example 0x04BB
becomes 0x04 + 0xBB = 0xBF
.
Noting the little-endian format, the correct bytes sequence for that request message is
0x42
, 0x52
, 0x02
, 0x00
, 0x06
, 0x00
, 0x00
, 0x00
, 0xBB
, 0x04
, 0x5B
, 0x01