BBIO Library "GPIOX_X" Access not working

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
sheridp_
 
Posts: 2
Joined: Fri Aug 15, 2014 5:50 pm

BBIO Library "GPIOX_X" Access not working

Post by sheridp_ »

When I use Adafruit_BBIO.GPIO python module, eg.

Code: Select all

import Adafruit_BBIO.GPIO as GPIO
GPIO.setup("P9_22", GPIO.OUT)
GPIO.output("P9_22", GPIO.HIGH)
Everything works. But if I instead refer to the pin as "GPIO0_2" as in

Code: Select all

import Adafruit_BBIO.GPIO as GPIO
GPIO.setup("GPIO0_2", GPIO.OUT)
GPIO.output("GPIO0_2", GPIO.HIGH)
It does not work, but the SRM says that it should be GPIO bank 0, pin 2.
Any idea why this is?

Also, as a side note, I noticed that

Code: Select all

GPIO.setup("I_HAVE_NO_BUSINESS_BEING_HERE", GPIO.OUT)
throws no error, which is a little weird. (Literally any valid python)

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: BBIO Library "GPIOX_X" Access not working

Post by tdicola »

It looks like the code right now uses the name column from the SRM, which for that pin is "UART2_RXD". Here's the table the library uses if you're curious, you can see the line which defines the pin and its possible names here:

Code: Select all

{ "UART2_RXD", "P9_22", 2, 3, -1},
So it looks like either the physical location P9_22 or name from the SRM is the way to address pins. Unfortunately the SRM and BeagleBone Black in general has a lot of possible pin functions and names so it can get a little confusing which one to use. In my experience the physical location name like P9_22 is the best one to use since it avoids a lot of confusion about which pin is which.

Great point about the error checking for the library--it's still in early development so there's definitely some things that could be improved. I'll be looking at fixing a few issues in the library in the next week so I'll see what kind of input validation is there and if it can be improved.

User avatar
sheridp_
 
Posts: 2
Joined: Fri Aug 15, 2014 5:50 pm

Re: BBIO Library "GPIOX_X" Access not working

Post by sheridp_ »

Tdicola,

Thanks for the reply. There is one problem with addressing the pins by their header numbers rather than GPIO numbers:
if you take a look at the BBB SRM, P9_41 and P9_42 are each connected to two GPIO ports, with the idea being that you would use one and set the other as an input (so it's not driven). Thus, it becomes necessary to use the GPIO address so that the two chip pins can be distinguished.

P.S. I've forked the "adafruit/Adafruit_Python_GPIO" and would be happy to help update and add functionality to the library. Let me know if there is a listserv or irc chat to join if there are other developers.

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: BBIO Library "GPIOX_X" Access not working

Post by tdicola »

Oh wow, interesting I didn't realize that was the intent with those pins. I wonder if bonescript really supports them--right now most of the config in the BBIO library is based off the config in bonescript. Looking at their config for those pins I only see one definition too. Looks like they ignore GPIO3_20 and GPIO3_18 right now.

Adding support to BBIO for those pins sounds great though--it might be kind of tricky since right now it only has a couple names defined for each pin. One option could be to define a third name in the array and update the logic to look at it too. I'm still a little new to the library myself but was wondering if putting more of the logic in the python code instead of the C extension would make more sense long term though. Perhaps loading the JSON config from bonescript and using that as a master source of all the pins and their functions since it's easy to parse JSON and process more complex data structures in python. I'll be looking more at the library this week to fix bugs and such in it and will think a bit about refactoring it in this way. Feel free to make any changes though and send a pull request with github. Thanks!

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”