'PIGPIO fails on startup, works on program relaunch

I am using pigpiod_if2.h to read the version of a shield on a Raspberry Pi 4B running a Buildroot distro as I need to have multiple C programs interacting with GPIO simultaneously -- the initialization uses pigpio_start, but returns error code -2003 on startup.

initGPIO = pigpio_start(NULL, NULL); // Initialise pigpio
    if (initGPIO >= 0) {
        printf("Initialised GPIO for HWConfig [pigpio]\n"); 
    } 
    else { 
        printf("Failed to initialise GPIO for HWConfig [pigpio]\n");
        printf("PIGPIO error code: %d\n", initGPIO);
    }

According to the documentation (from what I can tell) -2000 refers to the pigpiod header in some way, though there is no detail:

#define PI_PIGIF_ERR_0       -2000

And -3 refers to incorrect GPIO pin numbers:

#define PI_BAD_GPIO          -3 // GPIO not 0-53

However, I think this error may be a red herring, as when the process is relaunched (without rebooting the machine) it works perfectly, with a successful instantiation message and the correct version of the hardware read.

I would greatly appreciate troubleshooting help to try and identify the root cause of this issue. I have so far included a script that checks if pigpio is running before this program (it is), and removed all references to pigpio before this program, apart from the pigpio daemon check.

Thank you, H



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source