-
-
Notifications
You must be signed in to change notification settings - Fork 147
Interrupt call_back arguments #8
Comments
Typically you'd add interrupts with |
Chris, My problem was that Python threw an exception when an interrupt occurred saying that the call back routine required 3 arguments when I used “def gpio_callback( gpio_id, val ):”. Changing the function to “def gpio_callback( newarg, gpio_id, val):” worked. The first argument was equivalent to “self” in the call back function. The following is an abstract of the code that works. I have attached the actual code as testints.py Class TestInts :
RPIO.setup( self.INT_PIN, direction = RPIO.IN) RPIO.add_interrupt_callback( self.INT_PIN \
… Sorry for any confusion my previous post may have caused. I am new to Python but have > 50 yrs programming so far. I do appreciate what you did as it saved me a LOT of work. mailto:jhburkhard@gmail.com jhburkhard@gmail.com Phone 510-530-8568 Home Phone 510-338-0045 Cell From: Chris Hager [mailto:notifications@github.com] Typically you'd add interrupts with RPIO.add_interrupt_callback(...) (http://pythonhosted.org/RPIO/rpio_py.html#RPIO.add_interrupt_callback) — import RPIO class TestInts :
print "Interrupt on " + str( pin ) + " INTF Reg " + str( st ) + " val " + str( val )
|
I was unable to get a call back to work until I defined it with 3 arguments not 2 as noted in the documentation "def cb( me, pin, val) :" where "me" is a reference to the class so that class variables are referenced as me.xyz in the call back routine. Is this correct or am I doing something wrong?
Python 2.7 on Raspberry Pi wheezy updated.
My version of RPIO is "RPIO v0.10.0 (gpio-lib v0.10.0/0.4.2a)"
The text was updated successfully, but these errors were encountered: