Merge panda subtree

This commit is contained in:
Vehicle Researcher
2018-01-30 12:54:12 -08:00
14 changed files with 155 additions and 58 deletions

View File

@@ -18,6 +18,8 @@ __version__ = '0.0.6'
BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")
DEBUG = os.getenv("PANDADEBUG") is not None
# *** wifi mode ***
def build_st(target, mkfile="Makefile"):
@@ -34,7 +36,10 @@ def parse_can_buffer(dat):
address = f1 >> 3
else:
address = f1 >> 21
ret.append((address, f2>>16, ddat[8:8+(f2&0xF)], (f2>>4)&0xFF))
dddat = ddat[8:8+(f2&0xF)]
if DEBUG:
print(" R %x: %s" % (address, str(dddat).encode("hex")))
ret.append((address, f2>>16, dddat, (f2>>4)&0xFF))
return ret
class PandaWifiStreaming(object):
@@ -369,6 +374,8 @@ class Panda(object):
extended = 4
for addr, _, dat, bus in arr:
assert len(dat) <= 8
if DEBUG:
print(" W %x: %s" % (addr, dat.encode("hex")))
if addr >= 0x800:
rir = (addr << 3) | transmit | extended
else:
@@ -425,7 +432,10 @@ class Panda(object):
return b''.join(ret)
def serial_write(self, port_number, ln):
return self._handle.bulkWrite(2, struct.pack("B", port_number) + ln)
ret = 0
for i in range(0, len(ln), 0x20):
ret += self._handle.bulkWrite(2, struct.pack("B", port_number) + ln[i:i+0x20])
return ret
def serial_clear(self, port_number):
"""Clears all messages (tx and rx) from the specified internal uart