Skip to content

Commit

Permalink
Bugfix: prevent checksum computation errors mvillalba#25
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyCookie committed Apr 3, 2015
1 parent 4385a18 commit 7cf7dca
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/ant/core/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,11 @@ def setType(self, type_):
self.type_ = type_

def getChecksum(self):
data = chr(len(self.getPayload()))
data += chr(self.getType())
data += self.getPayload()

checksum = MESSAGE_TX_SYNC
for byte in data:
checksum = (checksum ^ ord(byte)) % 0xFF

checksum ^= len(self.payload)
checksum ^= self.type_
for byte in self.payload:
checksum = (checksum ^ ord(byte)) & 0xFF
return checksum

def getSize(self):
Expand Down

0 comments on commit 7cf7dca

Please sign in to comment.