Skip to content

Commit

Permalink
support newer pyserial for setBaudRate
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed May 23, 2016
1 parent 63d34ca commit 145ce80
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Firmware/tools/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,17 @@ def send(self, s):
self.port.write(s)
sys.stdout.write(s)

def setBaudrate(self, baudrate):
try:
self.port.setBaudrate(baudrate)
except Exception:
# for pySerial 3.0, which doesn't have setBaudrate()
self.port.baudrate = baudrate

def autosync(self):
'''use AT&UPDATE to put modem in update mode'''
if self.atbaudrate != 115200:
self.port.setBaudrate(self.atbaudrate)
self.setBaudrate(self.atbaudrate)
print("Trying autosync")
self.send('\r\n')
time.sleep(1.0)
Expand All @@ -342,11 +349,11 @@ def autosync(self):
time.sleep(0.7)
self.port.flushInput()
if self.atbaudrate != 115200:
self.port.setBaudrate(115200)
self.setBaudrate(115200)
print("Sent update command")
return True
if self.atbaudrate != 115200:
self.port.setBaudrate(115200)
self.setBaudrate(115200)
return False


Expand Down

0 comments on commit 145ce80

Please sign in to comment.