Simplified the VW checksum calculation that is just a simple bitwise XOR over the CAN message bytes.
This commit is contained in:
parent
5b9b4f56fb
commit
0bd378ccd6
1 changed files with 13 additions and 5 deletions
|
|
@ -160,14 +160,22 @@ class CanMessage(object):
|
|||
|
||||
'''
|
||||
Calculate the CRC checksum over the whole message.
|
||||
This works for the parameters used by VW, as a 0x00 byte somewhere in the message does not provide to the checksum.
|
||||
The VW implementation is a very simple implementation that cannot really be called a CRC: They simply do a bitwise
|
||||
XOR on the message data.
|
||||
|
||||
If this is true for all checksums is not certain! Has been tested for mMotor_5 and mMotor_6 only!
|
||||
'''
|
||||
def calculateCRC(self):
|
||||
crc = Crc(width=8, poly=0x01, reflect_in = False, reflect_out = False, xor_in = 0xff, xor_out = 0xff) # configure the crc calculator according to the VW parameters
|
||||
self.composeData()
|
||||
data = self.Data.tostring()
|
||||
my_crc = crc.bit_by_bit_fast(data)
|
||||
#crc = Crc(width=8, poly=0x01, reflect_in = False, reflect_out = False, xor_in = 0xff, xor_out = 0xff) # configure the crc calculator according to the VW parameters
|
||||
#self.composeData()
|
||||
#data = self.Data.tostring()
|
||||
#my_crc = crc.bit_by_bit_fast(data)
|
||||
#return my_crc
|
||||
|
||||
my_crc = 0;
|
||||
for i in range(len(self.Data)):
|
||||
my_crc ^= self.Data[i]
|
||||
|
||||
return my_crc
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue