How to use CRC16 to get a 2 byte result.
Closed this issue · 2 comments
JacoFourie commented
Hi.
I would like to use your library. How would I use it to get a result in an array buffer?
If I send it a string 'QPIGS' I know I need to get this result back
QPIGS$B7$A9 this is the command with 2 byte CRC ad last byte is a end of line chr(13)
If I use this hardcoded value it works. I want to get to the same result using the CRC16 from your library if possible.
command : array[1..8] of Byte = (byte('Q') , byte('P'), byte('I') , byte('G') , byte('S') , $B7 , $A9 , $0D );
JacoFourie commented
I have it working in Python using the crc16 library.
cmd = cmd.encode('utf-8')
crc = crc16.crc16xmodem(cmd).to_bytes(2,'big')
cmd = cmd+crc
cmd = cmd+b'\r'
while len(cmd)<8:
cmd = cmd+b'\0'
JacoFourie commented
I made another plan.