Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
interrupt serial port
#1
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
Reply
#2
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]
Reply
#3
I deleted your duplicate post under "Scripts and Snippets" Smile
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#4
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.
Recommended Tutorials:
Reply
#5
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.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#6
Just found another duplicate post in "General Coding", should this thread also be deleted?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#7
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?
Reply
#8
You may find this interesting: https://bytes.com/topic/python/answers/4...interrupts

Google is a wonderful, and quite useful, tool.
Reply
#9
(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).
Reply
#10
(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.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  MCU reboots after opening Serial port when ran from Raspberry PI zazas321 3 334 Mar-19-2024, 09:02 AM
Last Post: zazas321
  Waiting for input from serial port, then move on KenHorse 2 835 Oct-17-2023, 01:14 AM
Last Post: KenHorse
  pyserial/serial "has no attribute 'Serial' " gowb0w 9 3,331 Aug-24-2023, 07:56 AM
Last Post: gowb0w
  Serial Port As Global Prasanjith 2 1,422 Mar-23-2023, 08:54 PM
Last Post: deanhystad
  add interrupt for next task kucingkembar 0 752 Oct-07-2022, 12:15 PM
Last Post: kucingkembar
  Determine if keyboard interrupt versus SIGINT trapped? Jibunnokage 5 1,707 Sep-30-2022, 06:54 AM
Last Post: Gribouillis
  python serial port barryjo 2 1,603 Dec-27-2021, 11:09 PM
Last Post: barryjo
  is there a way to mention port range or search for port dynamically with qConnection Creepy 0 1,451 Sep-09-2021, 03:15 PM
Last Post: Creepy
  How to Properly Open a Serial Port in a Function bill_z 2 4,352 Jul-22-2021, 12:54 PM
Last Post: bill_z
  Enabling interrupt on Adafruits button/led board Moris526 0 1,987 Apr-30-2021, 03:29 PM
Last Post: Moris526

Forum Jump:

User Panel Messages

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