Last updated:
0 purchases
pythonttyduplicator 0.1.0
Utility that duplicates a serial port tty.
The main reason for using this tool is to log what is going through the tty.
Why create a “dummy” tty just to log ?
Well, a tty can only be read by ONE process. If two processes read the tty, each will read partial data from the tty.
Also, you can’t read the data going into the tty this way.
So this utility reads / writes to the real TTY, bridges it to a dummy tty, and logs everything going via the dummy tty.
Requirements
Python >=3.6
socat
Installation
You can install “python-tty-duplicator” via pip from PyPI:
$ pip install python-tty-duplicator
Usage
from tty_duplicator import TTYDuplicator
duplicator = TTYDuplicator(“/dev/ttyUSB0”, “serial_data.log”)
print(duplicator.fake_tty)
duplicator.start()
# Now you can interact with the “fake tty” and everything will be logged!
# e.g use picocom, tio, or pyserial
# Optional: will be called when python exits gracefully
duplicator.stop()
License
Distributed under the terms of the MIT license, “python-tty-duplicator” is free and open source software
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.