Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8621

General discussion • Re: Using GPIO on Pi5 from C/C++

$
0
0
For easy checking of things from the command line on Bookworm, use pinctrl
That is an excellent tool but should only be used for debugging and during testing - one shouldn't get into the habit of using it in a live environment or in production code. The issue is it goes behind 'libgpiod's back, voids the benefits of 'libgpiod', and can cause issues if accidentally touching GPIO one shouldn't be touching.

Using the standard 'libgpiod' commands is recommended; 'gpiodetect', 'gpioinfo', 'gpioset', 'gpioget', etc.

But, with 'libgpiod' 1.6.3 currently provided with Raspberry Pi OS Bookworm, it will be necessary to use 'pinctrl' to see what output levels a pin has been set to because 'gpioget' forces the pin read to become input. That should be resolved when Raspberry Pi OS adopts 'libgpiod' 2.0.1 or later where the '--as-is' option avoids that happening.

One may also have to use 'pinctrl' if the recommended commands won't allow access to a pin some other process has taken ownership of.

Statistics: Posted by hippy — Fri Jan 26, 2024 11:46 am



Viewing all articles
Browse latest Browse all 8621

Trending Articles