Question
Python and CRC8 verification
Posted on July 03, 2018 at 10:11
Helo friends,
I try calculate CRC8 in python and compare with CRC in STM And I have a problem.
My python CRC is return wrong value.
Python script:
def AddToCRC(b, crc):
b2 = b
for i in xrange(8):
odd = ((b2^crc) & 1) == 1
crc >>= 1
b2 >>= 1
if (odd):
crc ^= 0x8C
return crc�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
And I call this function here:
TestValue = [0, 0xAB, 0xFF]
check = 0
for i in TestValue:
check = AddToCRC(i, check)
print(hex(check))�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
And I get CRC8 in STM32F: 0x8B
And CRC from python script: 0xF8
Any idea, how to calculate CRC8 in python for STM32?
#crc8 #crc