Skip to content

Commit 6715f1c

Browse files
author
Nathan Seidle
committed
Uart loader now handles no response timeouts gracefully
1 parent d63ca26 commit 6715f1c

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

tools/artemis/artemis_uart_loader.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,35 @@ def main():
9797

9898
response = ser.read()
9999

100-
if(ord(response) == BL_COMMAND_ANNOUNCE):
101-
# Respond with 'AOK'
102-
# values = bytearray([6])
103-
ser.write(BL_COMMAND_AOK.to_bytes(1, byteorder='big'))
104-
105-
verboseprint("Bootload response received")
106-
break
107-
else:
108-
verboseprint("Unkown response: " + str(ord(response)))
109-
response = ''
100+
if(len(response) > 0):
101+
if(ord(response) == BL_COMMAND_ANNOUNCE):
102+
# Respond with 'AOK'
103+
# values = bytearray([6])
104+
ser.write(BL_COMMAND_AOK.to_bytes(1, byteorder='big'))
105+
106+
verboseprint("Bootload response received")
107+
break
108+
else:
109+
verboseprint("Unkown response: " + str(ord(response)))
110+
response = ''
110111

111112
# Send upload baud rate
112113
baud_in_bytes = args.baud.to_bytes(4, byteorder='big')
113114
ser.write(baud_in_bytes)
114115

116+
# Wait for incoming char indicating bootloader version
117+
i = 0
118+
response = ''
119+
while len(response) == 0:
120+
i = i + 1
121+
if(i == 10):
122+
print("No version from Artemis bootloader")
123+
exit()
124+
125+
response = ser.read()
126+
127+
verboseprint("Bootloader version: " + str(ord(response)))
128+
115129
ser.flush()
116130
# Wait for all previous bytes to transmit before changing bauds
117131
time.sleep(0.010)
1.15 KB
Binary file not shown.

0 commit comments

Comments
 (0)