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: 2573d861e605a2dcf456a6421b31e83fdd9ca606pull/176/head
parent
c251b312d8
commit
5f014635e1
15 changed files with 1130 additions and 1043 deletions
@ -1 +1 @@ |
||||
from .python import Panda, PandaWifiStreaming, PandaDFU, ESPROM, CesantaFlasher, flash_release, BASEDIR, ensure_st_up_to_date, build_st |
||||
from .python import Panda, PandaWifiStreaming, PandaDFU, ESPROM, CesantaFlasher, flash_release, BASEDIR, ensure_st_up_to_date, build_st, PandaSerial |
||||
|
@ -0,0 +1,27 @@ |
||||
# 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 |
||||
|
||||
|
@ -0,0 +1,48 @@ |
||||
#!/usr/bin/env python |
||||
import os |
||||
import time |
||||
import sys |
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) |
||||
from panda import Panda, PandaSerial |
||||
|
||||
def add_nmea_checksum(msg): |
||||
d = msg[1:] |
||||
cs = 0 |
||||
for i in d: |
||||
cs ^= ord(i) |
||||
return msg + "*%02X" % cs |
||||
|
||||
if __name__ == "__main__": |
||||
panda = Panda() |
||||
ser = PandaSerial(panda, 1, 9600) |
||||
|
||||
# power cycle by toggling reset |
||||
print "resetting" |
||||
panda.set_esp_power(0) |
||||
time.sleep(0.5) |
||||
panda.set_esp_power(1) |
||||
time.sleep(0.5) |
||||
print "done" |
||||
print ser.read(1024) |
||||
|
||||
# upping baud rate |
||||
# 460800 has issues |
||||
baudrate = 460800 |
||||
|
||||
print "upping baud rate" |
||||
msg = add_nmea_checksum("$PUBX,41,1,0007,0003,%d,0" % baudrate)+"\r\n" |
||||
print msg |
||||
ser.write(msg) |
||||
time.sleep(0.1) # needs a wait for it to actually send |
||||
|
||||
# new panda serial |
||||
ser = PandaSerial(panda, 1, baudrate) |
||||
|
||||
while True: |
||||
ret = ser.read(1024) |
||||
if len(ret) > 0: |
||||
sys.stdout.write(ret) |
||||
sys.stdout.flush() |
||||
#print str(ret).encode("hex") |
||||
|
Loading…
Reference in new issue