Skip to content

Commit

Permalink
fix exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gschaden committed Jan 12, 2023
1 parent 2f17707 commit db5e7b2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions microfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def flush_to_msg(serial, msg):
if not data.endswith(msg):
if COMMAND_LINE_FLAG:
print(data)
raise IOError("Could not enter raw REPL.")
raise IOError("Could not enter raw REPL. %s" % data)

def flush(serial):
"""Flush all rx input without relying on serial.flushInput()."""
Expand All @@ -93,9 +93,9 @@ def flush(serial):
serial.write(b"\r\x01")
flush_to_msg(serial, raw_repl_msg)
break
except:
# retry on exception, ignore
pass
except Exception as ex:
if i == 2: # retrying did not help
raise ex
# Soft Reset with CTRL-D
serial.write(b"\x04")
flush_to_msg(serial, b"soft reboot\r\n")
Expand Down

0 comments on commit db5e7b2

Please sign in to comment.