I’m trying to use InterruptAttachEvent() with pulse_attach(). My thought is
that I can use
the message handler code to crack the pulse code. I’m providing an int from
the parallel
port via IRQ 7. Another interrupt handler prototype using InterruptWait()
works, verifying
that I’m recognizing the signal appearing on pin 10 of the port. But despite
calling:
SIGEV_PULSE_INIT( &event, coid, SIGEV_PULSE_PRIO_INHERIT,
MSG_PULSE, 0 );
intrID = InterruptAttachEvent( 7, &event, _NTO_INTR_FLAGS_PROCESS |
_NTO_INTR_FLAGS_TRK_MSK );
pulse_attach(dpp, NULL, MSG_PULSE, message_callback, NULL );
the dispatch_block() function never returns. Can anyone provide any clues?
Thanks
// int7.c
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/neutrino.h>
#include <sys/dispatch.h>
#include <hw/inout.h>
#define MSG_PULSE _PULSE_CODE_MINAVAIL
int message_callback( message_context_t *ctp, int type, unsigned flags,
void *handle ) {
int num;
/* Print out some useful information on the message */
printf( “\n\nGot message:\n” );
printf( " type: %d\n" , type );
if ( type == MSG_PULSE ) {
printf(“PULSE\n”);
return 0;
}
return 0;
}
int main( int argc, char **argv ) {
unsigned char u37A;
message_attr_t message_attr;
dispatch_t *dpp;
dispatch_context_t *ctp, *ctp_ret;
int chid, coid, intrID;
struct sigevent event;
ThreadCtl( _NTO_TCTL_IO, 0 );
/* Create the Dispatch Interface */
dpp = dispatch_create();
if( dpp == NULL ) {
fprintf( stderr, “dispatch_create() failed: %s\n”,
strerror( errno ) );
return EXIT_FAILURE;
}
chid = ChannelCreate(0);
coid = ConnectAttach( 0, 0, chid, _NTO_SIDE_CHANNEL, 0 );
SIGEV_PULSE_INIT( &event, coid, SIGEV_PULSE_PRIO_INHERIT,
MSG_PULSE, 0 );
intrID = InterruptAttachEvent( 7, &event, _NTO_INTR_FLAGS_PROCESS |
_NTO_INTR_FLAGS_TRK_MSK );
pulse_attach(dpp, NULL, MSG_PULSE, message_callback, NULL );
/* Setup a context for the dispatch layer to use */
ctp = dispatch_context_alloc( dpp );
if( ctp == NULL ) {
fprintf( stderr, “dispatch_context_alloc() failed: %s\n”,
strerror( errno ) );
return EXIT_FAILURE;
}
/* The “Data Pump” - get and process messages */
while( 1 ) {
ctp_ret = dispatch_block( ctp );
if( ctp_ret ) {
dispatch_handler( ctp );
} else {
fprintf( stderr, “dispatch_block() failed: %s\n”,
strerror( errno ) );
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}