Skip to content

Commit

Permalink
feat: try to reopen the port every 100ms
Browse files Browse the repository at this point in the history
but still print a dot every 0.5 seconds
  • Loading branch information
2opremio committed Jul 17, 2024
1 parent 21df773 commit ee59cbb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion esp_idf_monitor/base/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
LAST_LINE_THREAD_INTERVAL = 0.1

MINIMAL_EN_LOW_DELAY = 0.005
RECONNECT_DELAY = 0.5 # timeout between reconnect tries
RECONNECT_DELAY = 0.1 # timeout between reconnect tries
CHECK_ALIVE_FLAG_TIMEOUT = 0.25 # timeout for checking alive flags (currently used by serial reader)

# closing wait timeout for serial port
Expand Down
11 changes: 9 additions & 2 deletions esp_idf_monitor/base/serial_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,23 @@ def run(self):
red_print(str(e))
yellow_print('Waiting for the device to reconnect', newline='')
self.close_serial()
last_dot_time = 0.0
waited_time = 0.0
while self.alive: # so that exiting monitor works while waiting
try:
time.sleep(RECONNECT_DELAY)
waited_time += RECONNECT_DELAY
# reset on reconnect can be unexpected for wakeup from deepsleep using JTAG
self.open_serial(reset=self.reset)
self.reset = False
break # device connected
except serial.SerialException:
yellow_print('.', newline='')
sys.stderr.flush()
if waited_time - last_dot_time > 0.5:
# print a dot every half second
last_dot_time = waited_time
yellow_print('.', newline='')
sys.stderr.flush()

yellow_print('') # go to new line
if data:
self.event_queue.put((TAG_SERIAL, data), False)
Expand Down

0 comments on commit ee59cbb

Please sign in to comment.