Skip to content

Commit

Permalink
leave msgs around in isotp
Browse files Browse the repository at this point in the history
  • Loading branch information
geohot committed Jan 23, 2018
1 parent 0acce2d commit b5e4962
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions examples/isotp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ def msg(x):
assert False
return ret.ljust(8, "\x00")

kmsgs = []
def recv(panda, cnt, addr, nbus):
global kmsgs
ret = []

while len(ret) < cnt:
kmsgs += panda.can_recv()
nmsgs = []
for ids, ts, dat, bus in kmsgs:
if ids == addr and bus == nbus and len(ret) < cnt:
ret.append(dat)
else:
# leave around
nmsgs.append((ids, ts, dat, bus))
kmsgs = nmsgs[-256:]
return map(str, ret)

def isotp_send(panda, x, addr, bus=0, recvaddr=None):
if recvaddr is None:
recvaddr = addr+8
Expand All @@ -30,22 +47,6 @@ def isotp_send(panda, x, addr, bus=0, recvaddr=None):
rr = recv(panda, 1, recvaddr, bus)[0]
panda.can_send_many([(addr, None, s, 0) for s in sends])

kmsgs = []
def recv(panda, cnt, addr, nbus):
global kmsgs
ret = []

while len(ret) < cnt:
kmsgs += panda.can_recv()
nmsgs = []
for ids, ts, dat, bus in kmsgs:
if ids == addr and bus == nbus and len(ret) < cnt:
ret.append(dat)
else:
pass
kmsgs = nmsgs
return map(str, ret)

def isotp_recv(panda, addr, bus=0, sendaddr=None):
msg = recv(panda, 1, addr, bus)[0]

Expand Down

0 comments on commit b5e4962

Please sign in to comment.