https://docs.beagleboard.org/latest/books/beaglebone-cookbook/02sensors/sensors.html#id28
That exact link will help you in Python3 for inputs via GPIO peripherals on the am335x (I think).
Seth
Update
I have not tried the file descriptors way w/ the above method from the docs. pages. The idea is to write to an input. First off, I do not know your system. If you use one of the beagleboard.org images they have made available, using config-pin
to set the mode works, the GPIOs are listed in /sys/class/gpio/*
, and gpiod works too.
Outside of working w/ their specific images (BSPs), I do not have a ton of experience using libraries but the language, w/ like what @benedict.hewson describes, while using file descriptors works w/ the BBB to my knowledge.
I have used various ways/languages to create useful ideas and presented them (either online or in person). Either way, I think the Adafruit_BBIO lib. stopped being publicly Open Source unless there are a few or a ton of people using it. If you track them down to see how they got it to work, it may be useful…
From the Docs…
# Make it an input pin
f = open(GPIOPATH+"/gpio"+pin+"/direction", "w")
f.write("in")
f.close()
So,
import WHATEVER_IS_NEEDED
import MORE_LIBS_WITHIN_PYTHON3
pin = '7' # P9_42 is gpio 7 and I do not know how gpio 7 is P9_42 yet?
GPIOPATH = "/sys/class/gpio" # or use /sys/class/gpio/THE_EXACT_GPIO(n)
# Make sure pin is EXPORTED IF NEEDED which it might not be needed?
if (not os.path.exists(GPIOPATH + "/gpio" + pin)):
f = open(GPIOPATH + "/export", "w")
f.write(pin)
f.close()
# Make it an input pin
f = open(GPIOPATH + "/gpio" + pin + "/direction", "w")
f.write("in")
f.close()
...
fancy source...
I think this could in theory work depending on your ideas and build. Did you allow access to GPIO in sysfs in your kernel? I know there must be more to add to the kernel than just sysfs access (if they still allow it)…
Another Update
I will test it. I know there must be a push button around here somewhere…
I will get back to you!
The last update
Okay. So, it works (sort of)… My source is lousy for now. I am still working on it. I am three hours in and edge and active_low seem to work as expected but I am not sure if they are the reasoning behind my source working just yet. I need to research more:
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt
will help you understand more.