Hello Sir,
Seth here. Here is an Adafruit_BBIO.GPIO example for handling a button
(abort on Rising): I got it from "The BeagleBone Black Primer (McLaughlin
2015)."
*import Adafruit_BBIO.GPIO as GPIO*
*Button = "P9_11"*
*GPIO.setup(Button, GPIO.IN)*
*if __name__=='__main__':*
* try:*
* while True:*
* GPIO.wait_for_edge(Button, GPIO.RISING)*
* except KeyboardInterrupt:*
* GPIO.cleanup()*
This example is on page 174.
Seth
P.S. I hope this helps a bit. I paraphrased but this is the oomph of it
all. If you are going to need other ideas, please let me know. I know, from
my own personal experience, that the BUSIO source may not be able to be
called w/ it working on this specific controller. I read, about a year
back, about how Circuit Python is trying to branch out and how some people
were trying to get it to work on the BBB. I am not convinced that it works
yet but I will research this idea more.
On Monday, March 1, 2021 at 9:31:25 PM UTC-6 set_ wrote:
> Hello,
>
> Are you using BBB_IO or Adafruit_BBIO?
>
> Either way, here is a start w/ Adafruit_BBIO:
>
> *import serial *
> *import Adafruit_BBIO.UART as UART *
> *from time import sleep*
>
>
> *UART.setup("UART2") *
> *ser=serial.Serial("/dev/ttyS2", 9600) *
>
> *class GPS: *
> * def __init__(self)*
>
> and then...
>
> If you want to add a button, just use a GPIO from Adafruit_BBIO again. So,
> that example will look like this:
>
> *import Adafruit_BBIO.GPIO as GPIO*
> *from time import sleep*
>
> *pinOne = 'P8_11'*
> *GPIO.setup(pinOne, GPIO.IN <http://GPIO.IN>)*
>
> *while True:*
> * if GPIO.input(pinOne):*
> * print("The Button Shall get pressed Again or whatever...")*
> * sleep(2)*
>
> That is a simplistic approach. I got that source from an older book:
> "Getting Started with BeagleBone (Richardson 2013)."
>
> There are some neat examples in that book but nothing too complicated. It
> would be a refresher to see what was then and what has changed.
>
> Anyway, I hope that works for you. That button function should just work.
> You can always do better and make it on an edge. Falling, Rising, or Both
> w/ that same lib.
>
> Seth
>
>
>
> On Monday, March 1, 2021 at 7:14:01 PM UTC-6 set_ wrote:
>
>> Hello,
>>
>> I am receiving errors w/ the .dtbo only. I am too far from outside to
>> communicate w/ my GPS and I am receiving no feedback w/ pyserial on my BBG
>> (BeagleBone Green). I tried installing a serial lib. w/ sudo apt install
>> python3-serial, also.
>>
>> I just downloaded/installed the docs in .epub/html format on my hard
>> drive. I am thinking it may or may not be Adafruit_BBIO. I am also thinking
>> that it may be or may not be pyserial. The intallation w/ apt was faulty
>> from the get-go.
>>
>> I can use config-pin p9.21 uart && config-pin p9.22 uart and have that
>> command turn successful.
>>
>> ...
>>
>> It may be a faulty effort in an update from pyserial but I am not sure
>> yet. If this means anything, please let me know:
>>
>> ^CTraceback (most recent call last):
>> File "./FirstGPS.py", line 87, in <module>
>> myGPS.read()
>> File "./FirstGPS.py", line 47, in read
>> while ser.inWaiting() == 0:
>> File
>> "/home/debian/.local/lib/python3.7/site-packages/serial/serialutil.py",
>> line 593, in inWaiting
>> def inWaiting(self):
>> KeyboardInterrupt
>>
>> The above error is only when I make no call to config-pin w/out a .dtbo
>> loaded. Also, pyserial is listed...
>>
>> Now...this source below is after making a config-pin call to P9.21/22 and
>> trying to exit my program:
>>
>> ^CTraceback (most recent call last):
>> File "./FirstGPS.py", line 87, in <module>
>> myGPS.read()
>> File "./FirstGPS.py", line 47, in read
>> while ser.inWaiting() == 0:
>> File
>> "/home/debian/.local/lib/python3.7/site-packages/serial/serialutil.py",
>> line 594, in inWaiting
>> return self.in_waiting
>> File
>> "/home/debian/.local/lib/python3.7/site-packages/serial/serialposix.py",
>> line 549, in in_waiting
>> s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
>> KeyboardInterrupt
>>
>> Both...are screaming to me about pyserial and those specific locations. I
>> add print statements and receive nothing back. So, I think my source, which
>> is an update from Python2 (from utf-8 to bytes) to Python3, is faulty.
>>
>> I can show you in case you are wondering. I am just updating some source
>> I found a while back.
>>
>> Seth
>>
>>
>> On Monday, March 1, 2021 at 6:47:56 PM UTC-6 [email protected] wrote:
>>
>>> You prompted me to recheck how I'm accessing the two peripherals I did
>>> get to install, the UART and the I2C. I'm only sending messages out over
>>> the UART using pyserial, although I do also use minicom to bi-directionally
>>> communicate with the board under test from the BBB Ubuntu command line. For
>>> the I2C I'm using the Adafruit char LCD library, which relies on busio from
>>> Circuit Python. Still an Adafruit product, but not technically the BBB_IO
>>> library, I guess.
>>>
>>> If anyone can give tips on how to do a button-based interrupt (abort)
>>> without BBB_IO, I'm all ears. I guess I could just start programming the
>>> BBB in C. I already program embedded microcontrollers in that language, so
>>> why not SBC?
>>>
>>>
>>> --
>>> Don Pancoe, P.E.
>>> Industrial Designer, Electrical Engineer
>>> DonPancoe.com <http://donpancoe.com/>
>>>
>>> On Mon, Mar 1, 2021 at 4:27 PM set_ <[email protected]> wrote:
>>>
>>>> Hello,
>>>>
>>>> I literally am havin' the same issue as you right now w/ a GPS module
>>>> working w/ BB-UART2-00A0.dtbo and a grove connector. This is my error:
>>>>
>>>> *py_setup_uart(UART2): set_pin_mode() failed for pin=P9_22Traceback
>>>> (most recent call last):*
>>>> * File "FirstGPS.py", line 5, in <module>*
>>>> * UART.setup("UART2")*
>>>> *ValueError: Set pin mode failed for uart channel.*
>>>>
>>>> I think things are changing at some point in some way at some level.
>>>> Vague...yes. I can set up my source w/out the .dtbo and use config-pin to
>>>> set my uart2 pins to have my source 'work.'
>>>>
>>>> Anyway, I will be following along to see how far you get b/c right now,
>>>> I am a little stumped as to why what has worked no longer is viable.
>>>>
>>>> Seth
>>>>
>>>> On Monday, March 1, 2021 at 12:27:01 PM UTC-6 [email protected] wrote:
>>>>
>>>>> Hello all,
>>>>>
>>>>> I have a BBB Python application (PCBA test fixture) where I am using
>>>>> libpruio, specifically for access to the eCAP pins. Libpruio requires
>>>>> that
>>>>> the universal cape be disabled, but when I needed a UART and I2C, I was
>>>>> able to add those back in using the existing dtbo files from
>>>>> /lib/firmware
>>>>> (shown below) in my uEnv.txt.
>>>>>
>>>>> uboot_overlay_addr0=/lib/firmware/BB-I2C1-00A0.dtbo
>>>>> uboot_overlay_addr1=/lib/firmware/BB-UART4-00A0.dtbo
>>>>> uboot_overlay_addr2=/lib/firmware/DP-GPIO-PCBATest-00A0.dtbo (I talk
>>>>> about this below)
>>>>>
>>>>>
>>>>> Now I want to add an "abort" button to the test fixture since the
>>>>> technicians have reported it takes a lot of time to reset if the board
>>>>> under test locks up. I expect that wiring a pushbutton to a GPIO with an
>>>>> interrupt is the way to handle this, and I've been thinking that there
>>>>> are
>>>>> two ways to get there.
>>>>>
>>>>> 1. Include another dtbo file to add a single GPIO that I can then
>>>>> access with Adafruit_BBIO (this is where my efforts have focused so
>>>>> far), or
>>>>> 2. Figure out how to work with the hardware-based IRQ of the PRU
>>>>> with libpruio (which I've been avoiding because it looks even more
>>>>> scary)
>>>>>
>>>>> I've tried to make a custom dtbo by following an example from Derek
>>>>> Molloy (github.com/derekmolloy/boneDeviceTree) and while it compiled
>>>>> and booted OK, I still get the following error when I run a simple test
>>>>> program. The same error as when I tried running the program before I
>>>>> created the dtbo.
>>>>>
>>>>> kapsul@beaglebone:~/pyDev$ sudo python3 abortTest.py
>>>>> Traceback (most recent call last):
>>>>> File "abortTest.py", line 6, in <module>
>>>>> GPIO.setup("P9_12", GPIO.IN)
>>>>> ValueError: Set gpio mode failed, missing file or invalid permissions.
>>>>>
>>>>>
>>>>> Further, when I do the following (with or without the dtbo), I get the
>>>>> following...
>>>>>
>>>>> kapsul@beaglebone:~/pyDev$ config-pin -q p9.12
>>>>> P9_12 pinmux file not found!
>>>>> Cannot read pinmux file:
>>>>> /sys/devices/platform/ocp/ocp*P9_12_pinmux/state
>>>>>
>>>>>
>>>>> Any input would be appreciated, whether it is correcting me on path 1
>>>>> or steering me towards path 2. I will happily provide any additional
>>>>> info,
>>>>> but I didn't want to start uploading stuff until I know what, exactly,
>>>>> will
>>>>> be helpful.
>>>>>
>>>>> Thanks,
>>>>> --
>>>>> Don Pancoe, P.E.
>>>>> Industrial Designer, Electrical Engineer
>>>>> DonPancoe.com <http://donpancoe.com/>
>>>>>
>>>> --
>>>> For more options, visit http://beagleboard.org/discuss
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "BeagleBoard" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/beagleboard/58e45b18-f019-49e7-92ce-95015cbc0e63n%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/beagleboard/58e45b18-f019-49e7-92ce-95015cbc0e63n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beagleboard/0a16689a-2dea-4d16-a2ad-cf489bb60b22n%40googlegroups.com.