I have a Problem with the following code. The InterruptWait_r routine timeouts allready after just 1 second despite the fact i set the timeout to 5s. Did I do anything wrong in the call to TimerTimeout() or InterruptWait()? This is my only project with QNX so I dont have a lot of experience with it.
void* int_thread_calotte(void *arg) {
// enable I/O privilege
ThreadCtl(_NTO_TCTL_IO, NULL);
// initialize
struct sigevent event;
SIGEV_INTR_INIT(&event);
// Clear interrupt, which is may pending by reading from input port
DiamondGarnet48Driver* pDigitalDriverGarnet48 = (DiamondGarnet48Driver*) InputOutputDriverFactory::getDigitalInOutDriver(DIGITAL_CARD);
pDigitalDriverGarnet48->clearInterrupt(2);
// attach the ISR to the IRQ
_interruptIdCalotte = InterruptAttach(HW_INTERRUPT_CALOTTE_SYNC, isr_handler_calotte, &event, sizeof(event), 0);
if (_interruptIdCalotte == -1) {
DEBUG_LOG << "SYNC: cant't attach to IRQ " << HW_INTERRUPT_CALOTTE_SYNC << std::endl;
exit(EXIT_FAILURE);
}
// Boost this thread's priority here
setprio(0, INT_THREAD_PRIO);
// Wait for the SYNC interrupt
struct sigevent eventIntr;
//eventIntr.sigev_notify = SIGEV_UNBLOCK;
SIGEV_UNBLOCK_INIT(&eventIntr);
uint64_t timeOut = static_cast<uint64_t>(5L * 1000000000L);
uint64_t otime = 0;
TimerTimeout( CLOCK_REALTIME, _NTO_TIMEOUT_INTR, &eventIntr, &timeOut, &otime);
if(InterruptWait_r(NULL, NULL) == ETIMEDOUT){
DEBUG_LOG << "Interrupt Wait timed out " << std::endl;
DEBUG_LOG << "otime=" << otime << std::endl;
_interrupWaitTimedOut = true;
return NULL;
}else{
_interrupWaitTimedOut = false;
}
// at this point, when InterruptWait unblocks,
// the ISR has returned a SIGEV_INTR, indicating
// that some form of work needs to be done
// Detach interrupts
InterruptDetach(_interruptIdCalotte);
return NULL;
}