How dose the checksum work in ascii protocol?

I’m working in python script to let Odrive work , but I really can’t understand the checksum in ascii protocl is how to work.
The official document said:

The ASCII protocol is human-readable and line-oriented, with each line having the following format:

command *42 ; comment [new line character]

  • *42 stands for a GCode compatible checksum and can be omitted. If and only if a checksum is provided, the device will also include a checksum in the response, if any. If the checksum is provided but is not valid, the line is ignored. The checksum is calculated as the bitwise xor of all characters before the asterisk (*).
    Example of a valid checksum: r vbus_voltage *93.
  • comments are supported for GCode compatibility
  • the command is interpreted once the new-line character is encountered

How can calculate ‘r vbus_voltage’ to ‘*93’

Finally,I know how can it be.
If you need to calculate ‘r vbus_voltage ’, just turning ‘r’ and ’ ’ to ASCII, and xor them to first checksum. Then, continue turing and xor them until the last one ’ '.
now you get the bitwise xor of all characters, you can get the ‘93’, after you turn it to ‘int’

1 Like