Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PySerial Question
#1
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!
Reply
#2
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.
Reply
#3
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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020