@@ -1338,7 +1338,7 @@ static void doVersion (char *argv []) | |||||
} | } | ||||
} | } | ||||
if (stat ("/dev/gpiomem", &statBuf) == 0) // User level GPIO is GO | |||||
if (wiringPiUserLevelAccess()) // User level GPIO is GO | |||||
printf (" * This Raspberry Pi supports user-level GPIO access.\n") ; | printf (" * This Raspberry Pi supports user-level GPIO access.\n") ; | ||||
else | else | ||||
printf (" * Root or sudo required for GPIO access.\n") ; | printf (" * Root or sudo required for GPIO access.\n") ; | ||||
@@ -2553,6 +2553,19 @@ void wiringPiVersion (int *major, int *minor) | |||||
} | } | ||||
int wiringPiUserLevelAccess(void) | |||||
{ | |||||
struct stat statBuf ; | |||||
const char* gpiomemModule = gpiomem_BCM; | |||||
if (PI_MODEL_5 == RaspberryPiModel) { | |||||
gpiomemModule = gpiomem_RP1; | |||||
} | |||||
return stat(gpiomemModule, &statBuf) == 0 ? 1 : 0; | |||||
} | |||||
/* | /* | ||||
* wiringPiSetup: | * wiringPiSetup: | ||||
* Must be called once at the start of your program execution. | * Must be called once at the start of your program execution. | ||||
@@ -206,6 +206,7 @@ extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ; | |||||
extern int GPIOToSysFS(const int pin) ; | extern int GPIOToSysFS(const int pin) ; | ||||
extern void wiringPiVersion (int *major, int *minor) ; | extern void wiringPiVersion (int *major, int *minor) ; | ||||
extern int wiringPiUserLevelAccess (void) ; | |||||
extern int wiringPiSetup (void) ; | extern int wiringPiSetup (void) ; | ||||
extern int wiringPiSetupSys (void) ; | extern int wiringPiSetupSys (void) ; | ||||
extern int wiringPiSetupGpio (void) ; | extern int wiringPiSetupGpio (void) ; | ||||