mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 15:53:57 +08:00
2573d86 docs say max is 4, respect the docs
864cd8f failing on some devices
54bcc67 Merge pull request #75 from gregjhogan/j2534-vs-2017-upgrade
1664270 Merge pull request #74 from gregjhogan/j2534-disconnect-fix
a7e3a8f bump panda version for serial bug
aa0cfad fix UART hang
09ab8f6 add sendaddr support to isotp
40a1883 fix up baud rate
65997ff add PandaSerial and location panda (aka pigeon) test
57d633c upgraded to VS 2017
35cc32a fixed pointer exception on disconnect
git-subtree-dir: panda
git-subtree-split: 2573d861e605a2dcf456a6421b31e83fdd9ca606
old-commit-hash: 5f014635e1
28 lines
692 B
Python
28 lines
692 B
Python
# mimic a python serial port
|
|
class PandaSerial(object):
|
|
def __init__(self, panda, port, baud):
|
|
self.panda = panda
|
|
self.port = port
|
|
self.panda.set_uart_parity(self.port, 0)
|
|
self.panda.set_uart_baud(self.port, baud)
|
|
self.buf = ""
|
|
|
|
def read(self, l=1):
|
|
tt = self.panda.serial_read(self.port)
|
|
if len(tt) > 0:
|
|
#print "R: ", tt.encode("hex")
|
|
self.buf += tt
|
|
ret = self.buf[0:l]
|
|
self.buf = self.buf[l:]
|
|
return ret
|
|
|
|
def write(self, dat):
|
|
#print "W: ", dat.encode("hex")
|
|
#print ' pigeon_send("' + ''.join(map(lambda x: "\\x%02X" % ord(x), dat)) + '");'
|
|
return self.panda.serial_write(self.port, dat)
|
|
|
|
def close(self):
|
|
pass
|
|
|
|
|