This commit is contained in:
mstroh76
2024-09-09 14:49:15 +02:00
parent b6bc43b562
commit 9e7c71f67d
4 changed files with 13 additions and 10 deletions

View File

@@ -1 +1 @@
3.9 3.10

View File

@@ -75,8 +75,9 @@ static void doReadallExternal (void)
********************************************************************************* *********************************************************************************
*/ */
#define MAX_ALTS 11
static const char unknown_alt[] = " - "; 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" "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) { static const char* GetAltString(int alt) {
if (alt>=0 && alt<=11) { if (alt>=0 && alt<=MAX_ALTS) {
return alts[alt]; return alts[alt];
} }

View File

@@ -1,3 +1,3 @@
#define VERSION "3.9" #define VERSION "3.10"
#define VERSION_MAJOR 3 #define VERSION_MAJOR 3
#define VERSION_MINOR 9 #define VERSION_MINOR 10

View File

@@ -1671,14 +1671,14 @@ int OpenAndCheckGpioChip(int GPIONo, const char* label, const unsigned int lines
return Fd; return Fd;
} else { } else {
if (wiringPiDebug) { 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; struct gpiochip_info chipinfo;
ZeroMemory(&chipinfo, sizeof(chipinfo)); ZeroMemory(&chipinfo, sizeof(chipinfo));
int ret = ioctl(Fd, GPIO_GET_CHIPINFO_IOCTL, &chipinfo); int ret = ioctl(Fd, GPIO_GET_CHIPINFO_IOCTL, &chipinfo);
if (0==ret) { if (0==ret) {
if (wiringPiDebug) { 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; int chipOK = 1;
if (label[0]!='\0' && NULL==strstr(chipinfo.label, label)) { 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; chipOK = 0;
} }
if (chipOK) { if (chipOK) {
printf ("%s: valid, fd=%d\n", szGPIOChip, Fd); if (wiringPiDebug) {
printf("%s: valid, fd=%d\n", szGPIOChip, Fd);
}
} else { } else {
if (wiringPiDebug) { 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); close(Fd);
return -1; // invalid chip return -1; // invalid chip
@@ -1710,7 +1712,7 @@ int wiringPiGpioDeviceGetFd() {
chipFd = OpenAndCheckGpioChip(4, "rp1", 54); // /dev/gpiochip4 @ Pi5 with older kernel chipFd = OpenAndCheckGpioChip(4, "rp1", 54); // /dev/gpiochip4 @ Pi5 with older kernel
} }
} else { } 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); chipFd = OpenAndCheckGpioChip(0, "bcm", 0);
} }
} }