Coder Social home page Coder Social logo

Comments (9)

metachris avatar metachris commented on July 29, 2024

I will take a look at it! Can you post your full script?

from rpio.

johnlauer avatar johnlauer commented on July 29, 2024
#!/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.

metachris avatar metachris commented on July 29, 2024

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.

johnlauer avatar johnlauer commented on July 29, 2024

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.

metachris avatar metachris commented on July 29, 2024

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.

johnlauer avatar johnlauer commented on July 29, 2024

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.

metachris avatar metachris commented on July 29, 2024

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.

johnlauer avatar johnlauer commented on July 29, 2024

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.

metachris avatar metachris commented on July 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.