Solved! Thank you rcgdlr.
I am just learning about CRCs and am unsure my implementation is correct. I have a number of questions:
Do I include the crc in the data portion (I believe I do but I'm unsure; could it depend on the implementation)?
bytes_trans = cmd_in[5:-2] # -2 to incl crc or -4 to excl crc?
How do I determine my initial value? Most implementations I saw online either used 0 or passed the crc itself. I have tried these two methods:
# CRC from the message crc_start = int.from_bytes(cmd_in[-4:-2], byteorder='little', signed=False) crc = binascii.crc_hqx(bytes_trans, crc_start) crc2 = binascii.crc_hqx(bytes_trans, 0)
How do I know when it works? I believe I'm looking for either a 0 out or an integer that matches the CRC?
I have not had success thus far which suggests I'm using the wrong inputs or the CRC is not actually a CCITT CRC-16 as specified in the documentation I am working from. I have tried most PyCRC implementations e.g. DNP and Kermit but have also had no luck. Is there a way to confirm that I am indeed working with a CCITT CRC-16? Are there factors that could have been implemented differently making this a slightly modified CCITT CRC-16?