Search code examples
serial-portputtychecksum

understanding checksum of ascii string


I am reading a manual on sending commands via serial to a device as shown: enter image description here

Assume that my equipment address is 000. I would send a command like: ">000P**cr".

what would **, my checksum be? According to the manual, I need the last two digits of the total char code of "000P".

Isn't that just the hex value of "P"? I can't seem to understand this.


Solution

  • Yes it's a bit confused, but my guess would be:

    total = ascii('0') + ascii('0') + ascii('0') + ascii('P')
    total = 48 + 48 + 48 + 80
    total = 224
    
    cksum = last2digits(total) = 24
    

    If it does not work as is, maybe try in hexadecimal notation:

    hex(total) = E0
    hex_cksum  = last2digits(hex(total)) = E0