Page 1 of 1

checksum for ComPort

Posted: Tue Jul 23, 2013 6:52 pm
by clamprod
I need to include a Checksum byte in my command line to the ComPort. Any direction in generating the packet checksum would be appreciated.

Thanks, folks!

Re: checksum for ComPort

Posted: Tue Jul 23, 2013 7:13 pm
by Tronic
this is an example in ruby

Code: Select all

string_data = @ins[0]

# this is line for test only, comment this to use input
string_data = "this is the data string"
####

checksum = 0
string_data.each_byte {|x| checksum ^= x }
output 0, checksum # with test line active this output have, checksum => 96

Re: checksum for ComPort

Posted: Sun Jul 28, 2013 3:50 am
by clamprod
Ah, awesome, Tronic!
Thank you!

clammy