diff --git a/fifo_bridge.py b/fifo_bridge.py index d5535c6..c78780d 100755 --- a/fifo_bridge.py +++ b/fifo_bridge.py @@ -4,9 +4,10 @@ import os import sys import time import mapid +from serial.serialutil import SerialException -FIFO = "/tmp/mapid.fifo" +FIFO = "/tmp/mapid" def main(): @@ -19,10 +20,7 @@ def main(): os.mkfifo(FIFO) time.sleep(0.2) print("Created FIFO " + FIFO, file=sys.stderr) - # f = open(FIFO, "w") - # f.write("\n") - # f.close() - # print("Created FIFO " + FIFO, file=sys.stderr) + f = open(FIFO, "r") print("Opened FIFO for reading", file=sys.stderr) m.cls() @@ -39,6 +37,9 @@ def main(): except KeyboardInterrupt: keep_going = False print() + except SerialException: + keep_going = False + print("Caught a SerialException. Exiting now...", file=sys.stderr) os.remove(FIFO) print("Removed FIFO.", file=sys.stderr)