From 8ca0819c0c154afbc395e42c5242c64ead9850c4 Mon Sep 17 00:00:00 2001 From: mstroh76 Date: Fri, 15 Mar 2024 15:37:54 +0100 Subject: [PATCH] #200 --- wiringPi/wiringPi.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index 28dfe61..1541bdf 100644 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -71,6 +71,7 @@ #include #include #include +#include #include "softPwm.h" #include "softTone.h" @@ -876,12 +877,26 @@ static void usingGpioMemCheck (const char *what) * ********************************************************************************* */ + const char* revfile = "/proc/device-tree/system/linux,revision"; void piGpioLayoutOops (const char *why) { - fprintf (stderr, "Oops: Unable to determine board revision from /proc/cpuinfo\n") ; - fprintf (stderr, " -> %s\n", why) ; - fprintf (stderr, " -> Check at https://github.com/wiringpi/wiringpi/issues.\n") ; + fprintf (stderr, "Oops: Unable to determine Raspberry Pi board revision from %s and from /proc/cpuinfo\n", revfile) ; + struct utsname sys_info; + if (uname(&sys_info) == 0) { + fprintf (stderr, " system name = %s\n", sys_info.sysname); + //fprintf (stderr, " node name = %s\n", sys_info.nodename); + fprintf (stderr, " release = %s\n", sys_info.release); + fprintf (stderr, " version = %s\n", sys_info.version); + fprintf (stderr, " machine = %s\n", sys_info.machine); + } + if (strstr(sys_info.machine, "arm") == NULL && strstr(sys_info.machine, "aarch")==NULL) { + fprintf (stderr, " -> This is not an ARM architecture; it cannot be a Raspberry Pi.\n") ; + fprintf (stderr, " -> WiringPi is designed for Raspberry Pi and can only be used with a Raspberry Pi.\n\n") ; + } else { + fprintf (stderr, " -> %s\n", why) ; + fprintf (stderr, " -> Check at https://github.com/wiringpi/wiringpi/issues.\n\n") ; + } exit (EXIT_FAILURE) ; } @@ -905,10 +920,6 @@ int piBoardRev (void) return piGpioLayout () ; } - -const char* revfile = "/proc/device-tree/system/linux,revision"; - - const char* GetPiRevision(char* line, int linelength, unsigned int* revision) { const char* c = NULL; @@ -1012,6 +1023,8 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty) unsigned int revision = 0x00 ; int bRev, bType, bProc, bMfg, bMem, bWarranty ; + //piGpioLayoutOops ("this is only a test case"); + c = GetPiRevision(line, maxlength, &revision); // device tree if (NULL==c) { c = GetPiRevisionLegacy(line, maxlength, &revision); // proc/cpuinfo