Comments (9)
I will take a look at it! Can you post your full script?
from rpio.
#!/usr/bin/env python
from time import sleep
#import RPi.GPIO as GPIO
import RPIO
import logging
log_format = '%(levelname)s | %(asctime)-15s | %(message)s'
logging.basicConfig(format=log_format, level=logging.DEBUG)
RPIO.setmode(RPIO.BCM)
# set up input channel with pull-up control
# (pull_up_down be PUD_OFF, PUD_UP or PUD_DOWN, default PUD_OFF)
RPIO.setup(17, RPIO.IN, pull_up_down=RPIO.PUD_OFF)
def do_something(gpio_id, value):
logging.info("New value for GPIO %s: %s" % (gpio_id, value))
RPIO.add_interrupt_callback(17, do_something, edge='both', threaded_callback=True)
do_something(17, -1)
logging.info("About to wait for interrupts")
RPIO.wait_for_interrupts()
from rpio.
OK! Can you replace the line RPIO.wait_for_interrupts()
with this and see if it helps?
try:
RPIO.wait_for_interrupts()
except KeyboardInterrupt:
RPIO.cleanup()
from rpio.
Ok. That seemed to do the trick. I’m just not sure I’ll always be able to do a perfect cleanup in all cases. This script will be running in an espresso machine and if the script dies for some random reason it is brought back up through a watchdog process. So a forced override when registering the callback is likely best. I suppose I could always do a cleanup first and then try to register the callback. You think that will work?
From: Chris Hager [mailto:[email protected]]
Sent: Saturday, February 23, 2013 12:51 PM
To: metachris/RPIO
Cc: John Lauer
Subject: Re: [RPIO] Don't get my interrupt registered unless change "rising" "falling" or "both" when launch my script (#1)
OK! Can you replace the line RPIO.wait_for_interrupts() with
try:
RPIO.wait_for_interrupts()
except KeyboardInterrupt:
RPIO.cleanup()
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-13997469.
from rpio.
Okay great -- I will update the documentation and add a fix to the next update which should go out tomorrow morning. After the update you won't have to do the cleanup manually anymore.
Thanks a lot for the feedback!
PS: You don't need to setup the gpio as input before using it for interrupts, so you can remove the RPIO.setup(17, ...)
line.
from rpio.
Ok, great.
If I don’t have to setup the PIN for interrupts, how can I set the pull up or down resistor on the pin?
From: Chris Hager [mailto:[email protected]]
Sent: Saturday, February 23, 2013 12:58 PM
To: metachris/RPIO
Cc: John Lauer
Subject: Re: [RPIO] Don't get my interrupt registered unless change "rising" "falling" or "both" when launch my script (#1)
Okay great -- I will update the documentation and add a fix to the next update which should go out tomorrow morning. After the update you won't have to do the cleanup manually anymore.
Thanks a lot for the feedback!
PS: You don't need to setup the gpio as input before using it for interrupts, so you can remove the RPIO.setup(17, ...) line.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-13997604.
from rpio.
You cannot set software pullups or pulldowns for interrupts as of yet. I'm working on it and hope to be able to include that soon. In the meantime please use a hardware resistor.
Edit: I was wondering -- did using setup(..)
with a pullup or -down have the desired effect?
from rpio.
Hmm. Ok. My circuit board design is already wrapped, but I might be able to pull off a hardware resistor.
From: Chris Hager [mailto:[email protected]]
Sent: Saturday, February 23, 2013 1:04 PM
To: metachris/RPIO
Cc: John Lauer
Subject: Re: [RPIO] Don't get my interrupt registered unless change "rising" "falling" or "both" when launch my script (#1)
You cannot set software pullups or pulldowns as of yet. I'm working on it and hope to be able to include that soon. In the meantime please use a hardware resistor.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-13997723.
from rpio.
I've just released RPIO v0.7.1 which also automatically cleans up the interfaces. Using this you won't need to call cleanup()
related with interrupts anymore. You can update to 0.7.1 like this:
$ rpio --update-rpio
or with easy_install:
$ sudo easy_install -U RPIO
from rpio.
Related Issues (20)
- RPIO ver.2 HOT 1
- Input function doen't work
- System hangs during reboot with RPIO python script running in docker HOT 1
- SystemError: This module can only be run on a Raspberry Pi! HOT 4
- Raspberry CM3 module unsupported. HOT 1
- Debian buster need #include <sys/sysmacros.h> inside pwm.c
- After upgrading to buster branch v2 stops working HOT 1
- Uncaught Error: Cannot find 'rpio'
- RPI 4 Model HOT 1
- RuntimeError: This module can only be run on a Raspberry Pi! HOT 2
- SystemError: This module can only be run on a Raspberry Pi!
- _PWM.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: makedev HOT 4
- how disable debbug ?
- RPIO-0.10.0-py3.5-linux-armv7l.egg SystemError: This module can only be run on a Raspberry Pi! HOT 1
- Interrupted by signal 11: SIGSEGV
- mmap check
- System error
- Problem running RPIO on Raspberry Pi 4 HOT 2
- RPIO won't run on my Raspberry Pi 4, how to remove? HOT 1
- https://pythonhosted.org/RPIO/#installation seems outdated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rpio.