Skip to content

Commit 37a079c

Browse files
committed
Limit baud rate for update bootloader
1 parent d828abe commit 37a079c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

artemis_uploader/asb/asb.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,17 @@ def upload(args, verboseprint):
378378
connection_timeout = 5
379379

380380
print('Connecting over serial port {}...'.format(args.port), flush=True)
381-
print('Baud rate:',args.baud)
381+
print('Requested baud rate:',args.baud)
382+
383+
useBaud = int(args.baud)
384+
if (useBaud > 115200):
385+
print('Limiting baud rate to 115200')
386+
useBaud = 115200
387+
useBaud = str(useBaud)
382388

383389
#Check to see if the com port is available
384390
try:
385-
with serial.Serial(args.port, args.baud, timeout=connection_timeout) as ser:
391+
with serial.Serial(args.port, useBaud, timeout=connection_timeout) as ser:
386392
pass
387393
except:
388394

@@ -417,7 +423,7 @@ def upload(args, verboseprint):
417423
# https://community.sparkfun.com/t/unable-to-flash-artemis-thing-plus-on-macos-sequoia/60766/6
418424
ser = serial.Serial()
419425
ser.port = args.port
420-
ser.baudrate = args.baud
426+
ser.baudrate = useBaud
421427
ser.timeout = connection_timeout
422428

423429
loadTries = 0
@@ -431,13 +437,13 @@ def upload(args, verboseprint):
431437

432438
ser.open()
433439

434-
time.sleep(0.01) #3ms and 10ms work well. Not 50, and not 0.
440+
time.sleep(0.008) #3ms and 10ms work well. Not 50, and not 0.
435441

436442
ser.dtr=False # Set RTS and DTR high
437443
ser.rts=False
438444

439445
#Give bootloader a chance to run and check bootload pin before communication begins. But must initiate com before bootloader timeout of 250ms.
440-
time.sleep(0.15)
446+
time.sleep(0.1) # 100ms works well
441447

442448
ser.reset_input_buffer() # reset the input bufer to discard any UART traffic that the device may have generated
443449

0 commit comments

Comments
 (0)