Skip to content

Commit

Permalink
kline checksum algo was broken...
Browse files Browse the repository at this point in the history
  • Loading branch information
jenstrange committed Mar 1, 2018
1 parent 3b7c33b commit 9390961
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ def kline_drain(self, bus=2):
ret = self._handle.controlRead(Panda.REQUEST_IN, 0xe0, bus, 0, 0x40)
if len(ret) == 0:
break
elif DEBUG:
print("kline drain: "+str(ret).encode("hex"))
bret += ret
return bytes(bret)

Expand All @@ -484,6 +486,7 @@ def kline_send(self, x, bus=2, checksum=True):
def get_checksum(dat):
result = 0
result += sum(map(ord, dat)) if isinstance(b'dat', str) else sum(dat)
result = -result
return struct.pack("B", result % 0x100)

self.kline_drain(bus=bus)
Expand Down

0 comments on commit 9390961

Please sign in to comment.