select_attach question 2

so i checked out the driver code, and the default io_notify() function is
being used. i also tried running the sample code that use select_attach()
from the library files for dispatch_create() at

http://www.qnx.com/developer/docs/momentics_nc_docs/neutrino/lib_ref/d/dispa
tch_create.html

when i run the sample code using two text files i get the same output as
that described below. the program goes into the dispatch loop, starts
executing dispatch_block, and then exits the program returning 0 without
printing any error messages or calling any callback functions. The
description of my code is below:

when i run the loop:

while(1){
printf("here\n ");
ctp_ret = dispatch_block(ctp);
if(ctp_ret){
printf(“dispatch handler\n”);
dispatch_handler(ctp);
} else {
fprintf(stderr, “dispatch_block: failure\n”);
return EXIT_FAILURE;
}
}
printf(“closing server\n”);
return EXIT_SUCCESS;

i get the following output:
the line “here” is printed
and then the program terminates, returning the value 0 without printing
anything else.

any ideas?


“David Gibbs” <dagibbs@qnx.com> wrote in message
news:adikqg$80s$2@nntp.qnx.com

sutin chen <> sutinchen@yahoo.com> > wrote:
a question about select_attach:

so i am using a device driver for a CAN bus, and i want to execute a
callback function everytime a message arrives on the CAN bus.

the CAN driver works by using a file descriptor. to read a message you
just
read from the file descriptor using read().

Ok.

correct me if i’m wrong, but i should be able to use select_attach() on
this
file descriptor and it should call a function everytime there is a
message
waiting to be read, right? as of the moment, the callback function is
never
called.

That depends.

Who wrote the CAN bus resource manager, and did they implement the
underlying support to make select() work?

select(), select_attach(), and io_notify() all use the _IO_NOTIFY
message, and if the resource manager for the CAN bus doesn’t handle
_IO_NOTIFY, then you will never unblock in your select_attach handler.

(You might want to make sure you’re using select_attach() properly
by testing against a resource manager where you know it is
implemented, e.g. a serial port, TCP/IP socket, or pseudo-tty.)

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.