Python Forum

Full Version: interrupt serial port
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hey everyboy

I am currently working on a project using raspberry pi 3 to read data through the serial port via putty 
and my question is: 

is there a way I can create an interrupt on python script to interrupt the program when the data is ready on the serial port 

please help me with this  Huh Huh Huh Huh Huh Huh Huh Huh
hey everyboy

I am currently working on a project using raspberry pi 3 to read data through the serial port via putty 
and my question is: 

is there a way I can create an interrupt on python script to interrupt the program when the data is ready on the serial port 

please help me with this  [Image: huh.png] [Image: huh.png] [Image: huh.png] [Image: huh.png] [Image: huh.png] [Image: huh.png] [Image: huh.png] [Image: huh.png]
I deleted your duplicate post under "Scripts and Snippets" Smile
I decapped your title
You should read
http://www.catb.org/esr/faqs/smart-questions.html
Quote:Don't TYPE IN ALL CAPS; this is read as shouting and considered rude.
First, please stop posting the same thing in multiple locations. Secondly, it is always helpful to see any code you've written so other users can supply tips, improvements, corrections and so forth which is more useful to you than a generic "Yes" to a generic question.
Just found another duplicate post in "General Coding", should this thread also be deleted?
Threads merged. Those of us that are here to help, check all the boards. There's no reason to post in more than one place.

Anyway, how are you reading data? Don't most interfaces just block until there's something to read?
You may find this interesting: https://bytes.com/topic/python/answers/4...interrupts

Google is a wonderful, and quite useful, tool.
(Feb-14-2017, 04:46 PM)nilamo Wrote: [ -> ]Threads merged.  Those of us that are here to help, check all the boards.  There's no reason to post in more than one place.

Anyway, how are you reading data?  Don't most interfaces just block until there's something to read?
With this line of code:

while true:
        s = serialport.readline()

which is run on the pi with the python script. A serial connection is between the pi and a desktop. As I type characters on the terminal (Putty) on the desktop, there should be an interrupt to say data is ready or a flag maybe. I dont want always listen to the serial port (Polling).
(Feb-15-2017, 06:43 AM)trainee1 Wrote: [ -> ]
(Feb-14-2017, 04:46 PM)nilamo Wrote: [ -> ]Threads merged.  Those of us that are here to help, check all the boards.  There's no reason to post in more than one place.

Anyway, how are you reading data?  Don't most interfaces just block until there's something to read?
With this line of code:

while true:
        s = serialport.readline()

which is run on the pi with the python script. A serial connection is between the pi and a desktop. As I type characters on the terminal (Putty) on the desktop, there should be an interrupt to say data is ready or a flag maybe. I dont want always listen to the serial port (Polling).

Start a thread that waits on a read of the serial port.