diff --git a/itm-decode.py b/itm-decode.py index 3f2b0be..86e4b3e 100755 --- a/itm-decode.py +++ b/itm-decode.py @@ -13,6 +13,20 @@ color_lookup = { "red": 31, "green": 32, "cyan": 36, "yellow": 33 } def color(name, text): return "\033[%dm%s\033[0m" % (color_lookup[name], text); +try: + # On Unix systems, print an additional marker in the output stream + # when SIGUSR1 or SIGUSR2 is received. This is just to help clarify + # output when the chip is externally reset, etc. + import signal + def sigusr1_handler(signum, frame): + print(color("yellow", "--- mark ---")) + def sigusr2_handler(signum, frame): + print(color("yellow", "--- reset ---")) + signal.signal(signal.SIGUSR1, sigusr1_handler) + signal.signal(signal.SIGUSR2, sigusr2_handler) +except AttributeError as e: + pass + class ResyncException(Exception): pass