I am currently trying to capture serial data within a python script. I intend to begin capturing a log of all the data captured on a serial port while the rest of the script continues to interact with the system I am testing.
If I use pyserial I believe it will end up blocking the rest of the tests I want to carry out until I finish logging.
My options I have considered are:
- Writing another script to capture logs using pyserial, call this script using subprocess.Popen()
- Using built in unix tools such as tail or cat and calling these with subprocess.Popen()
I am sure I could find a way to get either of these to work, but if anyone knows of a more direct way of doing it then I would love to know.
Thank you in advance.
Why create another process for reading data from pySerial ?
For non-blocking the read you can configure the timeout in serial class.
e.g.
Also look at the wrapper class for reference.
http://pyserial.sourceforge.net/examples.html#wrapper-class
You can run a thread to keep reading the data from serial and update it to the buffer.
Creating another process invloves the overhead of IPC and not recommended for this task.