Skip to content

Commit fce08ab

Browse files
committed
Update dispatcher.py
1 parent e60869b commit fce08ab

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

code/shproto/dispatcher.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ def start(sn=None):
8181
READ_BUFFER = max(nano.in_waiting, READ_BUFFER)
8282

8383
try:
84-
rx_byte_arr = nano.read(size=READ_BUFFER)
84+
with threading.Lock():
85+
rx_byte_arr = nano.read(size=READ_BUFFER)
86+
time.sleep(0.01)
8587
except serial.SerialException as e:
8688
if "device disconnected" in str(e):
87-
logger.error("Device disconnected. Attempting to reconnect...")
88-
# Add reconnection logic or gracefully terminate
89+
logger.error("Device disconnected. Attempting to reconnect...\n")
90+
with threading.Lock():
91+
rx_byte_arr = nano.read(size=READ_BUFFER)
8992
else:
9093
logger.error(f"SerialException: {e}")
9194
break

0 commit comments

Comments
 (0)