Browse Source

Add ability to add output marker via external signal

For example, a script to flash the chip can use this to mark the
output so that it's clear when the target was actually reset.
master
Jim Paris 3 years ago
parent
commit
b9562c04e0
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      itm-decode.py

+ 14
- 0
itm-decode.py View File

@@ -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



Loading…
Cancel
Save