Hello QNX Prorammers
I tried to set a timeout for a InterruptWait() call by calling timer_timeout()
but it does’nt seem to work it just hangs at the InterruptWait() call forever.
So I did a little Test Programm where I extracted the relevant code and it does’nt woth there either. I pasted the code of the test programm below.
I must do something wrong but I just dont see it.
#include <cerrno>
#include <cstdlib>
#include <unistd.h>
#include <iostream>
#include <pthread.h>
#include <sys/neutrino.h>
#include <sys/siginfo.h>
#include <hw/inout.h>
int _interruptIdCalotte = 0;
// Interrupt service routine ISR
// called when the calotte sync signal occurs
const struct sigevent* isr_handler_calotte(void *arg, int id) {
struct sigevent* event = (struct sigevent*) arg;
//std::clog << "id: "<<id<<" _interruptIdCalotte: "<<_interruptIdCalotte<< std::endl;
// Check the interrupt source
if (id != _interruptIdCalotte) {
return NULL;
}
return event;
}
void* int_thread_calotte(void *arg) {
// enable I/O privilege
ThreadCtl(_NTO_TCTL_IO, NULL);
// initialize
struct sigevent event;
SIGEV_INTR_INIT(&event);
// attach the ISR to the IRQ
// _interruptIdCalotte = InterruptAttachEvent( 7, &event, 0);
_interruptIdCalotte = InterruptAttach(7, isr_handler_calotte, &event, sizeof(event), 0);
if (_interruptIdCalotte == -1) {
std::exit(EXIT_FAILURE);
}
// Boost this thread's priority here
setprio(0, 63);
struct sigevent timerEvent;
struct timespec timeout;
SIGEV_INTR_INIT (&timerEvent);
//timerEvent.sigev_notify = SIGEV_UNBLOCK;
timeout.tv_sec = 4;
timeout.tv_nsec = 0;
timer_timeout( CLOCK_REALTIME, _NTO_TIMEOUT_INTR, &timerEvent, &timeout, NULL );
std::clog << "SYNC: Wait for the calotte sync interrupt" << std::endl;
if(InterruptWait(NULL, NULL) == ETIMEDOUT){
std::clog << "Interrupt Wait timed out " << std::endl;
}
// Detach interrupts
InterruptDetach(_interruptIdCalotte);
return NULL;
}
int main(int argc, char *argv[]) {
// Start up a thread that waites until calotte sync interrupt occurs
// after the defines delay (iDelayAfterSyncMs) the thread will terminate
pthread_t threadId;
pthread_create(&threadId, NULL, int_thread_calotte, NULL);
// Blocks until thread has terminated
pthread_join(threadId, NULL);
}