Hi!
I'm getting a string from a device that's connected on a serial-port that looks like this;
STX Text text text ... CR ETX BCC
Where STX=0x02, ETX=0x03, CR=0x0d and BCC is the checksum 0x00-0xFF.
The checksum should be calculated using XOR of everything exept STX and BCC.
But how should I do that using Perl? I've found lots of C examples but no Perl ... can I just XOR character by character or do I need to do some XOR bit by bit?
I'm using Device::Serialport and I've got everything in a string, and then I'm using a for-loop and substr to get character by character - I don't know if that's the correct way to do it.
Thanks för any help!
Best regards, Lars Fredriksson
I'm getting a string from a device that's connected on a serial-port that looks like this;
STX Text text text ... CR ETX BCC
Where STX=0x02, ETX=0x03, CR=0x0d and BCC is the checksum 0x00-0xFF.
The checksum should be calculated using XOR of everything exept STX and BCC.
But how should I do that using Perl? I've found lots of C examples but no Perl ... can I just XOR character by character or do I need to do some XOR bit by bit?
I'm using Device::Serialport and I've got everything in a string, and then I'm using a for-loop and substr to get character by character - I don't know if that's the correct way to do it.
Thanks för any help!
Best regards, Lars Fredriksson