Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

BOARD numbering with interrupts #6

Open
dbrgn opened this issue May 12, 2013 · 4 comments
Open

BOARD numbering with interrupts #6

dbrgn opened this issue May 12, 2013 · 4 comments

Comments

@dbrgn
Copy link

dbrgn commented May 12, 2013

Is it currently possible to use the BOARD numbering scheme with interrupts? It doesn't currently seem to work.

I tried to set an interrupt on GPIO 2 (BOARD 3). When using RPIO.setmode(RPIO.BOARD) and add an interrupt callback to pin 3, I get an InvalidChannelException ("not a valid pin").

With RPIO.BCM and pin 2 it works though. Which is a little strange as pin 3 would be a valid GPIO pin with BCM numbering too.

Is this some bug? Do the interrupts not support the BOARD numbering?

@mattvenn
Copy link

mattvenn commented Jul 2, 2013

same for me.

@metachris
Copy link
Owner

Thanks for the feedback. I'll be taking a look into it tomorrow!

@chapster911
Copy link

Have encountered the same issue still. Oct 2013.

@thismatters
Copy link

Still seeing this issue. I'm trying to use GPIO 25 (BOARD 22), and getting the same exception.

I've tried it out and found that BOARD pins 3, 7, 8, 11, 21, 22 Yield the 'not a valid pin' version of the exception

BOARD pin 13 gives the 'outside of range' version of the exception

The following board pins seem to initialize fine: 5, 10, 12, 15, 16, 18, 23, 24.

This is a really frustrating problem, and I don't know your code well (so forgive my presumption), but I think the evidence points to an answer.

In _RPIO.py (within the add_interrupt_callback() definition) on line 125 you translate from whatever numbering system was established by RPIO.setmode() to the proper GPIO numbers (BCM) by calling channel_to_gpio(), the exception isn't thrown there. Then on line 139 of _RPIO.py you call RPIO.gpio_function(), passing the (now BCM) gpio_id; within py_gpio_function() you take that gpio_id (which is using the BCM numbering) and you pass it again to channel_to_gpio(), this is where the error is thrown because that function expects the gpio_id to be relative to RPIO.BOARD (since that is still the set mode). Perhaps if you pass the unmolested channel_id to RPIO.gpio_function() on line 139 rather than the gpio_id it will work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants