I Found a Lib! Yes, it is from Someone Else...

Hello,

Now, this should cover everything I found out for now. If this is not the place for this idea, okay. I can remove it. If this is okay w/ the forums, okay too. Good actually. People in general are falling behind while others w/ access are gaining. Now, that computers while I am in the US are probably in every household, this should be a normalcy. Right? Anyway, if this does not work, please describe why or what issues you are coming across. Who knows who might have something to say?

I know people may be looking for libs. or other ways to interface to the BBB or other like am335x boards (STILL)!

uname -r : 5.10.100-ti-r40
cat /etc/dogtag : BeagleBoard.org Debian Bullseye IoT Image 2022-03-12

So, here goes it:


git clone https://github.com/mvduin/overlay-utils # This is where the BBORG_RELAY-00A2.dtbo is made from currently...
git clone https://github.com/mvduin/sysfs-gpio # This is the library to use for C processing...

If you are like me and goof around and test out items in files/directories, along w/ making mistakes, /etc/udev/rules.d/ has many files and if you absolutely demolish your image and kernel by accident, try this for this particular instance:


# /etc/udev/rules.d/80-gpio-noroot.rules
#
# ReWritten by: Matthijs van Duin
# Corrects sys GPIO permissions on the BB so non-root users in the gpio group can manipulate bits
#
SUBSYSTEM=="gpio", ACTION=="add", \
	RUN+="/bin/chgrp -R gpio '/sys%p'", \
	RUN+="/bin/chmod -R g=u '/sys%p'"

SUBSYSTEM=="subsystem", KERNEL=="gpio", ACTION=="add", \
	RUN+="/bin/chgrp gpio '/sys/class/gpio/export' '/sys/class/gpio/unexport'", \
	RUN+="/bin/chmod g=u '/sys/class/gpio/export' '/sys/class/gpio/unexport'"

This will allow you to run the GPIO in question so you can handle using this library or any lib. of your choosing w/out root permissions, i.e. as the user debian.

Some test code for GPIO on the BBBW w/ RelayCape attached for blinking a LED on/off.


#include "sysfs-gpio.h"
#include <stdio.h>
#include <unistd.h>

unsigned int mSeconds = 5000000;
int returnCode;


int main()
{
        struct Gpio gpio = GPIO_INITIALIZER;

        gpio_open_output( &gpio, "/dev/gpio/relay-jp3", false );
        while (1) {
                gpio_is_output( &gpio );
                        gpio_write( &gpio, false );
                        returnCode = usleep(mSeconds);
                        gpio_write( &gpio, true );
                        returnCode = usleep(mSeconds);
        }
        gpio_close( &gpio );
        return 0;
}

The gpio_close( &gpio ); section in the source is mundane. You can see why it is “mundane.” I am in a while loop w/ this lib. until I cancel the lib. source w/ CTRL-C. This overrides my source and should not be done but it is done for a brief time to signify this simple source I made w/ some help.

This is some sound library action in case people are looking for new ways to interface their boards and knowledge in C/C++.

Seth

P.S. If you are using the RelayCape and are wanting to use your switches for LED action, a simple C & P is available. Oh, one last thing. I completely understand that Open Source does not mean Free Source. So, if you are using this lib, please come forward and show off what you may want to do or what you already have done. Simple ideas go and long way.

  1. make in the overlays-utils dir. after cloning will build the .dtsi into a .dtbo for you to use.
  2. make in the sysfs-gpio dir. after cloning will build the source to use for this lib.
  3. In the Makefile under the sysfs-gpio dir, please add your custom script name from above so the make command will build your source into a file name so one can run it from the command line.
  4. Oh! Attach your .dbto for the RelayCape in /boot/uEnv.txt to handle, after a reboot, the GPIOs in question for your Super Collider or just a plain, ole LED! Ha.

I think some of the ideas related to specific libraries are changing. I can never be sure. If you see changes that do not work, please forgive me. I will try to update sooner or later.