From 58fd2654a387fda7739f071fd86fb11fb21da545 Mon Sep 17 00:00:00 2001 From: mstroh76 Date: Fri, 26 Apr 2024 17:45:12 +0200 Subject: [PATCH] #219 report /dev/gpiochip support --- gpio/gpio.c | 8 ++++++-- wiringPi/wiringPi.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gpio/gpio.c b/gpio/gpio.c index 1e7ec59..fb2da2f 100644 --- a/gpio/gpio.c +++ b/gpio/gpio.c @@ -1363,7 +1363,7 @@ static void doVersion (char *argv []) piModelNames [model], piRevisionNames [rev], piMemorySize [mem], piMakerNames [maker], warranty ? "[Out of Warranty]" : "") ; // Check for device tree - printf ("System details:\n") ; + printf ("\nSystem details:\n") ; if (stat ("/proc/device-tree", &statBuf) == 0) { // We're on a devtree system ... printf (" * Device tree present.\n") ; } @@ -1394,9 +1394,13 @@ static void doVersion (char *argv []) } else { printf (" * Does not support basic user-level GPIO access via /dev/gpiomem.\n") ; if(0==bGlobalAccess) { - printf (" * root or sudo may be required for GPIO access.\n") ; + printf (" * root or sudo may be required for direct GPIO access.\n") ; } } + if (GetChipFd()>0) { + printf (" * Supports basic user-level GPIO access via /dev/gpiochip (slow).\n") ; + } + } diff --git a/wiringPi/wiringPi.h b/wiringPi/wiringPi.h index 029b6bb..81c4001 100644 --- a/wiringPi/wiringPi.h +++ b/wiringPi/wiringPi.h @@ -218,6 +218,7 @@ extern int wiringPiSetupGpio (void) ; extern int wiringPiSetupPhys (void) ; extern int wiringPiSetupGpioDevice(void) ; //Interface 3.3 +extern int GetChipFd (); extern void pinModeAlt (int pin, int mode) ; extern void pinMode (int pin, int mode) ; extern void pullUpDnControl (int pin, int pud) ;