fifo_bridge.py: Catch SerialException; default FIFO without extension
This commit is contained in:
parent
23195805be
commit
8f54104f5c
1 changed files with 6 additions and 5 deletions
|
@ -4,9 +4,10 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import mapid
|
import mapid
|
||||||
|
from serial.serialutil import SerialException
|
||||||
|
|
||||||
|
|
||||||
FIFO = "/tmp/mapid.fifo"
|
FIFO = "/tmp/mapid"
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -19,10 +20,7 @@ def main():
|
||||||
os.mkfifo(FIFO)
|
os.mkfifo(FIFO)
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
print("Created FIFO " + FIFO, file=sys.stderr)
|
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")
|
f = open(FIFO, "r")
|
||||||
print("Opened FIFO for reading", file=sys.stderr)
|
print("Opened FIFO for reading", file=sys.stderr)
|
||||||
m.cls()
|
m.cls()
|
||||||
|
@ -39,6 +37,9 @@ def main():
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
keep_going = False
|
keep_going = False
|
||||||
print()
|
print()
|
||||||
|
except SerialException:
|
||||||
|
keep_going = False
|
||||||
|
print("Caught a SerialException. Exiting now...", file=sys.stderr)
|
||||||
|
|
||||||
os.remove(FIFO)
|
os.remove(FIFO)
|
||||||
print("Removed FIFO.", file=sys.stderr)
|
print("Removed FIFO.", file=sys.stderr)
|
||||||
|
|
Loading…
Reference in a new issue