fix
This commit is contained in:
@ -41,10 +41,15 @@ DATA_PATH = "/tmp/ttyADC_data"
|
|||||||
# DataReader
|
# DataReader
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
class DataReader:
|
class DataReader:
|
||||||
"""Non-blocking raw reader for /tmp/ttyADC_data."""
|
"""Non-blocking raw reader for /tmp/ttyADC_data (PTY-safe)."""
|
||||||
|
|
||||||
def __init__(self, path=DATA_PATH):
|
def __init__(self, path=DATA_PATH):
|
||||||
|
import termios, tty
|
||||||
self._fd = os.open(path, os.O_RDONLY | os.O_NOCTTY)
|
self._fd = os.open(path, os.O_RDONLY | os.O_NOCTTY)
|
||||||
|
try:
|
||||||
|
tty.setraw(self._fd) # disable line discipline processing
|
||||||
|
except termios.error:
|
||||||
|
pass # not a TTY — fine, skip
|
||||||
os.set_blocking(self._fd, False)
|
os.set_blocking(self._fd, False)
|
||||||
|
|
||||||
def read_available(self):
|
def read_available(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user