The New Character Device Idea?

Make GPIO easy and easier but do not try to make it a given...

Categories: Beginner

Hello…

I found a couple of interesting "facts" on a couple of pages. I liked what I read and I liked what I watched on this specific instance of ideas.

Look here:

https://github.com/adafruit/adafruit-beaglebone-io-python/issues/157

and here…

https://github.com/sgjava/userspaceio

and ultimately here…

https://github.com/brgl/libgpiod

If you catch up to these ideas and want to use the idea of a character device instead of a sysfs entry on GPIO, awesome! Oh and if not, that is okay too!

3.3v -> 220 ohm resistor -> LED -> P9_12 or GPIO_60″></p>
<p>This is a Fritzing rendering of the BBB and an "equipped" breadboard.</p>
<p>…</p>
<p><span>From adding </span><br />
<strong>libkmod-dev</strong><br />
<span> and </span><br />
<strong>libudev-dev</strong><br />
<span> on your Debian Distro from </span><br />
<a href=bbb.io/latest-images,
you should be able to build the tests from
https://github.com/brgl/libgpiod
and use those tools to light up a LED.

Also, if the above statements do not work correctly, try to use this cmd:
sudo

apt

install

autoconf-archive
and that should do it for setting up your libgpiod utility. Oh! If you do not have the prerequisites for this idea, you may need to get autoconf and m4. A quick search will guide you through those two libraries and the set up that must ensue. Okay!

Using that image and Kernel w/ the Debian Distro!

After looking over the ideas on brgl/libgpiod on GitHub.com, please follow these instructions which can be found at the same place:

To build the project (including command-line utilities) run:    

./autogen.sh --enable-tools=yes --prefix=<install path>    

make    

make install


Where it states "–prefix=<install path>", please install whichever path you see as easy to view and move around in w/ Linux and your terminal.

Next, type gpioinfo at your command prompt/terminal.

You will get a list of ideas pertaining to your gpiochips and line numbers which will inevitably be used to acquire your correct pin name and header, e.g. P8_xx and/or P9_xx.

gpioinfo will accumulate a bunch of ideas on your terminal. See below:

This is from the cmd gpioinfo and the print shows my gpiochip1 w/ 32 lines.

I will be making my 3.3v from my BeagleBone Black Wireless run a LED via character device and libgpiod.

So now, w/ the help of libgpiod and the tools installed, we can finally make our LED light up like Christmas. Here goes it but first…we need to use another cmd:

gpioset --mode=wait gpiochip1 28=0


So, for this cmd, we are calling gpioset at the cmd line, setting –mode=wait which waits for a return key to be pressed for cancellation, and then using our gpiochip1 and line 28 values b/c we have our LED hooked up to P9_12 which is line 28 on gpiochip1. On my BBB/BBBW, I have four different gpiochip values all w/ corresponding line numbers.

So, I am going to run the cmd gpioset –mode=wait gpiochip1 28=0 and it should, if all things are set up correctly, light up the LED and stay lit until I press the return key/enter. A photo should render this to be true. If you are in doubt, please consult someone of higher knowledge than I or give me a shout out and let me know what is happening to your side of things.

Here, you can see the difference in what is going on in the terminal when I run the character device/libgpiod set of instructions and while the command is actually being ran!

Running examples...

This was me running a set of cmds and seeing the output. The first line in this set of cmds blinked the LED while the second line did nothing. I blinked the LED once more and then allowed the LED to stay on w/ gpioset –mode=wait gpiochip1 28=0.

While the example is running and the LED is on!

In this example, I did all of what I described earlier but allowed for the –mode=wait option to hold my LED on and I did not press the return key. Enter was pressed afterwards to cancel the LED lighting.

Lighting an LED in UserSpace!

So…I think that is it.

Seth

P.S. Oh and depending on if your gpiochip and line number of which header and pin number are equaling, use =0 or =1 after the line number to pick if you want the LED on or off. Um…yep! That is all for now!

Comments are not currently available for this post.