PySerial Question - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: PySerial Question (/thread-5946.html) |
PySerial Question - PythonMan - Oct-30-2017 Hello, I have installed PySerial and have been playing with its capabilities. I am somewhat new all around to Python as well as PySerial. I am looking to see if I can write a routine that would allow the Python script to wait until a specific message is displayed across the serial port? For instance, if I wanted to do print('Hello') every time the word Geoffrey came across the serial port? I think I might start with a while statement, but beyond that I am puzzled as to how to get the system to wait for an event that matches the criteria. Thanks! RE: PySerial Question - Larz60+ - Oct-30-2017 If you run your serial process as a thread, you can have it wait for a message. See: http://greenteapress.com/wp/semaphores/ to get some knowledge on this. RE: PySerial Question - PythonMan - Oct-30-2017 Threading is an interesting approach. I will have to research this and try it. I've seen some people implementing the time.sleep values, etc. with conditional IF statements, but I think there might be a better or easier way that I am not thinking of. |