fifo_bridge.py: Catch SerialException; default FIFO without extension

This commit is contained in:
Malte Bublitz 2023-10-26 15:33:39 +02:00
parent 23195805be
commit 8f54104f5c
Signed by: malte70
GPG Key ID: 605DA5C729F9C184
1 changed files with 6 additions and 5 deletions

View File

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