Catching event returned by interrupt

I have an interrupt started with InterruptAttach(), which return a pulse when some processing have
to be done at thread level.
My question is: How do I catch this pulse in the worker thread?

Here is the code:

void* workerThread(void * arg)
{
extern struct VDCA_ISR_com_area VDCA_ISR_comBuf;
unsigned int call_counter = 0;
int channel_ID;
struct _pulse rcv_pulse;
struct _msg_info msg_info_debug;


//----- create communication channel -----
channel_ID = ChannelCreate( 0 );
if( -1 == channel_ID ){
TRACE(“workerThread: Channel creation failed: %s\n”, strerror(errno) );
return NULL;
}


//----- initialize VDCA ISR event -----
SIGEV_PULSE_INIT( VDCA_ISR_comBuf.event, channel_ID, getprio(0), eVDCA_pulseCode, eVDCA_none );


int Isr_ID = InterruptAttach( PPC85xx_INTR_IRQ0,
vdcaIsr,
&VDCA_ISR_comBuf,
sizeof(VDCA_ISR_comBuf),
_NTO_INTR_FLAGS_TRK_MSK );
if( Isr_ID != -1){
TRACE(“Interrupt attached successfully, Isr_ID = %d\n”, Isr_ID);
}
else{
TRACE(“Failled to attach interrupt: %s\n”, strerror(errno));
return NULL;
}


/**************************

  • Processing loop     *
    

**************************/
while(1)
{
//----- wait for pulse from ISR -----
if( MsgReceive( channel_ID, &rcv_pulse, sizeof(rcv_pulse), &msg_info_debug ) >= 0 ){

=== MsgReceive NEVER UNBLOCK ===

printf("*** workerThread() got a message or a pulse ***\n");

}
}//while(1)

return NULL;
}

Armand Ciejak <armand.ciejak@free.fr> wrote:

You’re missing a ConnectAttach() – the pulse description structure
take a connect id, not a channel id, to identify the channel.

Updated your code…

(Note, also, MsgReceive() will NEVER fill in a msg info structure
for a pulse.)

-David

Here is the code:

void* workerThread(void * arg)
{
extern struct VDCA_ISR_com_area VDCA_ISR_comBuf;
unsigned int call_counter = 0;
int channel_ID;
struct _pulse rcv_pulse;
struct _msg_info msg_info_debug;



//----- create communication channel -----
channel_ID = ChannelCreate( 0 );
if( -1 == channel_ID ){
TRACE(“workerThread: Channel creation failed: %s\n”, strerror(errno) );
return NULL;
}

connection_ID = ConnectAttach( 0, 0, channel_ID, _NTO_SIDE_CHANNEL, 0 );


//----- initialize VDCA ISR event -----
SIGEV_PULSE_INIT( VDCA_ISR_comBuf.event, channel_ID, getprio(0), eVDCA_pulseCode, eVDCA_none );

SIGEV_PULSE_INIT( VDCA_ISR_comBuf.event, connection_ID, getprio(0), eVDCA_pulseCode, eVDCA_none );


int Isr_ID = InterruptAttach( PPC85xx_INTR_IRQ0,
vdcaIsr,
&VDCA_ISR_comBuf,
sizeof(VDCA_ISR_comBuf),
_NTO_INTR_FLAGS_TRK_MSK );
if( Isr_ID != -1){
TRACE(“Interrupt attached successfully, Isr_ID = %d\n”, Isr_ID);
}
else{
TRACE(“Failled to attach interrupt: %s\n”, strerror(errno));
return NULL;
}



/**************************

  • Processing loop     *
    

**************************/
while(1)
{
//----- wait for pulse from ISR -----
if( MsgReceive( channel_ID, &rcv_pulse, sizeof(rcv_pulse), &msg_info_debug ) >= 0 ){

=== MsgReceive NEVER UNBLOCK ===

printf("*** workerThread() got a message or a pulse ***\n");

}
}//while(1)

return NULL;
}


David Gibbs
QNX Training Services
dagibbs@qnx.com

Thanks it’s now working fine :slight_smile:

David Gibbs wrote:

Armand Ciejak <> armand.ciejak@free.fr> > wrote:

You’re missing a ConnectAttach() – the pulse description structure
take a connect id, not a channel id, to identify the channel.

Updated your code…

(Note, also, MsgReceive() will NEVER fill in a msg info structure
for a pulse.)

-David


Here is the code:


void* workerThread(void * arg)
{
extern struct VDCA_ISR_com_area VDCA_ISR_comBuf;
unsigned int call_counter = 0;
int channel_ID;
struct _pulse rcv_pulse;
struct _msg_info msg_info_debug;



//----- create communication channel -----
channel_ID = ChannelCreate( 0 );
if( -1 == channel_ID ){
TRACE(“workerThread: Channel creation failed: %s\n”, strerror(errno) );
return NULL;
}


connection_ID = ConnectAttach( 0, 0, channel_ID, _NTO_SIDE_CHANNEL, 0 );



//----- initialize VDCA ISR event -----
SIGEV_PULSE_INIT( VDCA_ISR_comBuf.event, channel_ID, getprio(0), eVDCA_pulseCode, eVDCA_none );


SIGEV_PULSE_INIT( VDCA_ISR_comBuf.event, connection_ID, getprio(0), eVDCA_pulseCode, eVDCA_none );



int Isr_ID = InterruptAttach( PPC85xx_INTR_IRQ0,
vdcaIsr,
&VDCA_ISR_comBuf,
sizeof(VDCA_ISR_comBuf),
_NTO_INTR_FLAGS_TRK_MSK );
if( Isr_ID != -1){
TRACE(“Interrupt attached successfully, Isr_ID = %d\n”, Isr_ID);
}
else{
TRACE(“Failled to attach interrupt: %s\n”, strerror(errno));
return NULL;
}



/**************************

  • Processing loop     *
    

***********************/
while(1)
{
//----- wait for pulse from ISR -----
if( MsgReceive( channel_ID, &rcv_pulse, sizeof(rcv_pulse), &msg_info_debug ) >= 0 ){


=== MsgReceive NEVER UNBLOCK ===


printf("
workerThread() got a message or a pulse ***\n");


}
}//while(1)


return NULL;
}