Deinitialization Failure

I’m running a data collection script (all sensors except GPS) and upon exiting of the script I get this in the command window:

NavDAQ_raw: deinitialization failed

This did not occur before the PPM script was changed (output enable). A google search suggests that this is due to an object not being ‘destroyed’ properly before exit. Not sure why this is occurring now and was wondering if anyone had any insight.

@larssoltmann

Hello! Could you be a little more elaborate on the code you’re using? I’m particularly interested how PPM script is called.

Inside the main program I have (among other things):

static const uint8_t outputEnablePin = RPI_GPIO_27;
Pin pin(outputEnablePin);
if (pin.init()) {
    pin.setMode(Pin::GpioModeOutput);
    pin.write(0); /* drive Output Enable low */
} else {
    error_flag++;
}

 pthread_t PPMThread;

    if(pthread_create(&PPMThread, NULL, PPMDecode, (void *)arg) !=0)
{
    error_flag++;
}

Inside PPMDecode I have:

void * PPMDecode(void * args){

gpioCfgClock(samplingRate, PI_DEFAULT_CLK_PERIPHERAL, 0);
gpioInitialise();
previousTick = gpioTick();
gpioSetAlertFunc(ppmInputGpio, ppmOnEdge);

}

The ppmOnEdge function is identical to that in the example script. If it makes a difference, there are three other threads running as well (data collection loops for MS5611, MS5805, AHRS) and none of them are ‘stopped’ before the main program exits. I did some digging into pthread_exit but since the AHRS and PPM thread are infinite loops (at least I have them written that way), I’m not sure where to put it in them. Also not exiting the threads does not seem to cause any problems. Some forums have suggested using an atomic boolean to tell the threads when to stop but other have said that is poor practice. The ‘deinitialization failure’ that pops up after exiting doesn’t seem to impact anything, all my data is still written to a file properly, so I was more just curious as to why it is happening.

@larssoltmann

It was actually my bad!

Updated master. You can pull the changes. Thanks for the feedback.

1 Like