From 9e7c71f67d58013dc0e08a8c50cdbb8d1c0624a0 Mon Sep 17 00:00:00 2001 From: mstroh76 Date: Mon, 9 Sep 2024 14:49:15 +0200 Subject: [PATCH] #280 --- VERSION | 2 +- gpio/readall.c | 5 +++-- version.h | 4 ++-- wiringPi/wiringPi.c | 12 +++++++----- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index bd28b9c..c8cfe39 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.9 +3.10 diff --git a/gpio/readall.c b/gpio/readall.c index c28f7fe..8d2ffba 100644 --- a/gpio/readall.c +++ b/gpio/readall.c @@ -75,8 +75,9 @@ static void doReadallExternal (void) ********************************************************************************* */ +#define MAX_ALTS 11 static const char unknown_alt[] = " - "; -static const char *alts [] = +static const char *alts [MAX_ALTS+1] = { "IN", "OUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3", "ALT6", "ALT7", "ALT8", "ALT9" } ; @@ -84,7 +85,7 @@ static const char *alts [] = static const char* GetAltString(int alt) { - if (alt>=0 && alt<=11) { + if (alt>=0 && alt<=MAX_ALTS) { return alts[alt]; } diff --git a/version.h b/version.h index 3daf967..8ef452a 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ -#define VERSION "3.9" +#define VERSION "3.10" #define VERSION_MAJOR 3 -#define VERSION_MINOR 9 +#define VERSION_MINOR 10 diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index ae4656b..bc00369 100644 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -1671,14 +1671,14 @@ int OpenAndCheckGpioChip(int GPIONo, const char* label, const unsigned int lines return Fd; } else { if (wiringPiDebug) { - printf ("wiringPi: Open chip %s succeded, fd=%d\n", szGPIOChip, Fd) ; + printf("wiringPi: Open chip %s succeded, fd=%d\n", szGPIOChip, Fd) ; } struct gpiochip_info chipinfo; ZeroMemory(&chipinfo, sizeof(chipinfo)); int ret = ioctl(Fd, GPIO_GET_CHIPINFO_IOCTL, &chipinfo); if (0==ret) { if (wiringPiDebug) { - printf ("%s: name=%s, label=%s, lines=%u\n", szGPIOChip, chipinfo.name, chipinfo.label, chipinfo.lines) ; + printf("%s: name=%s, label=%s, lines=%u\n", szGPIOChip, chipinfo.name, chipinfo.label, chipinfo.lines) ; } int chipOK = 1; if (label[0]!='\0' && NULL==strstr(chipinfo.label, label)) { @@ -1688,10 +1688,12 @@ int OpenAndCheckGpioChip(int GPIONo, const char* label, const unsigned int lines chipOK = 0; } if (chipOK) { - printf ("%s: valid, fd=%d\n", szGPIOChip, Fd); + if (wiringPiDebug) { + printf("%s: valid, fd=%d\n", szGPIOChip, Fd); + } } else { if (wiringPiDebug) { - printf ("%s: invalid, search for '%s' with %u lines!\n", szGPIOChip, label, lines) ; + printf("%s: invalid, search for '%s' with %u lines!\n", szGPIOChip, label, lines) ; } close(Fd); return -1; // invalid chip @@ -1710,7 +1712,7 @@ int wiringPiGpioDeviceGetFd() { chipFd = OpenAndCheckGpioChip(4, "rp1", 54); // /dev/gpiochip4 @ Pi5 with older kernel } } else { - // not sure if all Pis have 54 lines (Pi1v1, Pi1v2 and CM ?), so this check is disabled + // not all Pis have same number of lines: Pi0, Pi1, Pi3, 54 lines, Pi4, 58 lines (CM ?), see #280, so this check is disabled chipFd = OpenAndCheckGpioChip(0, "bcm", 0); } }