I want to log the serial output of a device.
To do so, I need to
- Send a 1 second DTR pulse that resets the device
- Use a non-interactive serial monitor that outputs to stdout
So far I have not found any shell tools that can do any of the two in non-interactive mode. The idea is to start it from a systemd user service so the program can run persistently after user session stops.
Example
$ pulse-dtr /dev/ttyUSB0
$ serial-read /dev/ttyUSB0 | multilog s10000000 n5 ~/logs/
PS: I'm open to simple python scripts too
You can manipulate the DTR signals with Python pyserial, which is probably available as a package in your distribution under a similar name. Perhaps some usb serial devices may not implement it, however. You can use the same package to set the baud rate and read from the port:
You may need to set the dtr to False then True, rather than True then False. This program reads a single character and writes it unbuffered to stdout, so you can pipe this into another program.