![AgileX SCOUT 2.0 User Manual Download Page 22](http://html1.mh-extra.com/html/agilex/scout-2-0/scout-2-0_user-manual_2868819022.webp)
AgileX Robotics (Dongguan) Co.,Ltd.
21
byte [1]
Current front light mode
unsigned int8
0x00 NC
0x01 NO
0x02 BL mode
0x03 User-defined brightness
byte [2]
Current custom
brightness of front light
unsigned int8
[0, 100], where 0 refers to no brightness,
100 refers to maximum brightness
byte [3]
Current rear light mode
unsigned int8
0x00 NC
0x01 NO
0x02 BL mode
0x03 User-defined brightness
[0, 100], where 0 refers to no brightness,
100 refers to maximum brightness
byte [4]
Current custom
brightness of rear light
unsigned int8
byte [5]
Reserved
--
0x00
byte [6]
Count parity bit (count)
unsigned int8
0 - 255 counting loops, which will be
added once every command sent
byte [7]
Parity bit (checksum)
unsigned int8
Parity bit
The data Parity bit is the last valid byte in the data segment of each frame of CAN message. Its
checksum is calculated as follows: checksum =(ID_H + ID_L + data can_msg.data[0]
+ can_msg.data[1] + can_msg.data[2] + can_msg.data[3] +can_msg.data[4]+ …+
can_msg.data[n]) & 0xFF:
•
ID_H and ID_L are respectively higher 8 bits and lower 8 bits of a frame ID.For example,
if ID is 0x540, the corresponding ID_H is 0x05 and ID_L is 0x40;
•
Data_length refers to the valid data length of a data segment in one frame of CAN message,
which includes the checksum byte;
•
can_msg.data[n] is the specific content of each byte in the valid data segment; the count
parity bit needs to participate in the calculation of checksum, but the checksum itself does
not participate in the calculation.
/**
*
@brief
CAN message checksum example code
* @param[in]id : can id
* @param[in]*data : can message data struct pointer
* @param[in]len : can message data length
*
@return
the checksum result
*/
staticuint8
Agilex_CANMsgChecksum
(
uint16
id
,
uint8
*
data
,
uint8
len
)
{
uint8
checksum
=
0x00
;
checksum
=(
uint8
)(
id
&
0x00ff
)+(
uint8
)(
id
>>
8
)+
len
;
for
(
uint8
i
=
0
;
i
<(
len
-
1
);
i
++)
{
checksum
+=
data
[
i
];