Resource mgr with data from timer tick

bridged with qdn.public.qnxrtp.os
Post Reply
Harry Qualls

Resource mgr with data from timer tick

Post by Harry Qualls » Sun Jan 11, 2004 6:44 pm

I am currently developing a resource manager to provide data from one of our
scanning systems to various clients. The data are obtained from laser
sensors, but only when triggered by an external source. The "standard"
resource manager approach uses an io_write operation to store data to be
made available. In my case I periodically poll an external device to
initiate a new scan. In the course of developing the code I had to poke
various values into the resource manager's underlying data structures. This
strikes me as inelegant. Would anyone like to comment on a tidier way to
accomplish this? For instance, it occurred to me that perhaps the timer tick
routine would open the resource manager using an fd and write the data just
like an external process would. Or could one simply call io_write with the
correct arguments from the timer tick routine? Any comments?

static int cnt; // diagnostic for testing

int
timer_tick(message_context_t *ctp, int code, unsigned flags, void *handle) {
union sigval value = ctp->msg->pulse.value;
if ( ++cnt % 5 == 4 ) { // simulate new data after 4 ticks
device_attr[0].attr.nbytes = strlen(test_replies[0]);
device_attr[0].data = test_replies[0];
// _IO_SET_WRITE_NBYTES( resmgr_context_t *ctp, int nbytes ) // is this
needed here??
device_attr[0].notify[IOFUNC_NOTIFY_INPUT].cnt = 1; // forces a
notify
device_attr[0].attr.flags |= IOFUNC_ATTR_MTIME | IOFUNC_ATTR_CTIME;
}
if (IOFUNC_NOTIFY_INPUT_CHECK(device_attr[0].notify, 1, 0))
iofunc_notify_trigger(device_attr[0].notify, 1, IOFUNC_NOTIFY_INPUT);
return 0;
}

Thanks in advance.

Post Reply

Return to “qdn.public.qnxrtp.os”