mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-22 00:33:44 +08:00
openpilot v0.7.7 release
This commit is contained in:
committed by
Adeeb Shihadeh
parent
9e7fb4680d
commit
b205dd6954
+18
-13
@@ -1,4 +1,5 @@
|
||||
import binascii
|
||||
import time
|
||||
|
||||
DEBUG = False
|
||||
|
||||
@@ -34,22 +35,22 @@ def isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr):
|
||||
# TODO: handle other subaddr also communicating
|
||||
assert msg[0] == subaddr
|
||||
|
||||
if msg[1]&0xf0 == 0x10:
|
||||
if msg[1] & 0xf0 == 0x10:
|
||||
# first
|
||||
tlen = ((msg[1] & 0xf) << 8) | msg[2]
|
||||
dat = msg[3:]
|
||||
|
||||
# 0 block size?
|
||||
CONTINUE = bytes([subaddr]) + b"\x30" + b"\x00"*6
|
||||
CONTINUE = bytes([subaddr]) + b"\x30" + b"\x00" * 6
|
||||
panda.can_send(sendaddr, CONTINUE, bus)
|
||||
|
||||
idx = 1
|
||||
for mm in recv(panda, (tlen-len(dat) + 5)//6, addr, bus):
|
||||
for mm in recv(panda, (tlen - len(dat) + 5) // 6, addr, bus):
|
||||
assert mm[0] == subaddr
|
||||
assert mm[1] == (0x20 | (idx&0xF))
|
||||
assert mm[1] == (0x20 | (idx & 0xF))
|
||||
dat += mm[2:]
|
||||
idx += 1
|
||||
elif msg[1]&0xf0 == 0x00:
|
||||
elif msg[1] & 0xf0 == 0x00:
|
||||
# single
|
||||
tlen = msg[1] & 0xf
|
||||
dat = msg[2:]
|
||||
@@ -61,9 +62,9 @@ def isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr):
|
||||
|
||||
# **** import below this line ****
|
||||
|
||||
def isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None):
|
||||
def isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None, rate=None):
|
||||
if recvaddr is None:
|
||||
recvaddr = addr+8
|
||||
recvaddr = addr + 8
|
||||
|
||||
if len(x) <= 7 and subaddr is None:
|
||||
panda.can_send(addr, msg(x), bus)
|
||||
@@ -96,11 +97,16 @@ def isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None):
|
||||
rr = recv(panda, 1, recvaddr, bus)[0]
|
||||
panda.can_send(addr, sends[-1], 0)
|
||||
else:
|
||||
panda.can_send_many([(addr, None, s, 0) for s in sends])
|
||||
if rate is None:
|
||||
panda.can_send_many([(addr, None, s, bus) for s in sends])
|
||||
else:
|
||||
for dat in sends:
|
||||
panda.can_send(addr, dat, bus)
|
||||
time.sleep(rate)
|
||||
|
||||
def isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None):
|
||||
if sendaddr is None:
|
||||
sendaddr = addr-8
|
||||
sendaddr = addr - 8
|
||||
|
||||
if subaddr is not None:
|
||||
dat = isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr)
|
||||
@@ -113,13 +119,13 @@ def isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None):
|
||||
dat = msg[2:]
|
||||
|
||||
# 0 block size?
|
||||
CONTINUE = b"\x30" + b"\x00"*7
|
||||
CONTINUE = b"\x30" + b"\x00" * 7
|
||||
|
||||
panda.can_send(sendaddr, CONTINUE, bus)
|
||||
|
||||
idx = 1
|
||||
for mm in recv(panda, (tlen-len(dat) + 6)//7, addr, bus):
|
||||
assert mm[0] == (0x20 | (idx&0xF))
|
||||
for mm in recv(panda, (tlen - len(dat) + 6) // 7, addr, bus):
|
||||
assert mm[0] == (0x20 | (idx & 0xF))
|
||||
dat += mm[1:]
|
||||
idx += 1
|
||||
elif msg[0] & 0xf0 == 0x00:
|
||||
@@ -134,4 +140,3 @@ def isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None):
|
||||
print("R:", binascii.hexlify(dat))
|
||||
|
||||
return dat
|
||||
|
||||
|
||||
Reference in New Issue
Block a user