Spectracom - Essential Ingenuity

GSG-L1 Checksum Calculation


How Do I Calculate the GSG-L1 Checksum?


To calculate the checksum, remove the initial sign and asterisk sign, then XOR the first byte of the result with a decimal zero. Each subsequent byte is XORd with the previous result. The final result is a decimal value which must be converted to its respective hexadecimal value, which is the checksum.

def cksum(s):
msg = map(ord, s[1:s.index('*')])
sum = reduce(xor, msg)
ret="%02x" % (sum)
return ret
if __name__ == '__main__':
str = "?PLPARM0010:0f:000a*"
print str + cksum(str)

The user must note that LF, linefeed, is used as line (i.e. command) terminator.

Was this information helpful?

 Yes  No