Best way to poll the parallel port?

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

2 posts / 0 new
Last post
Best way to poll the parallel port?

Submitted by Anonymous (not verified) on Fri, 06/15/2012 - 12:07

hello all,
I wrote a program in motif to work with the parallel port, but i have run into a problem. I was trying to use a driver to handle interrupts on the parallel port, but I have resorted to polling data lines rather than using interrupts - due to frustration with kernel issues.
Anyways, When I click on a buttuon, I would like for my program to run through a loop and continuously check the parallel port for its status.
My real question is, when I am in a loop, nothing else will respond - can't click on other buttons. In Visual Basic there is a solution - the DoEvents call. In perl/Tk, there is the DoOneEvent call. This allows the processor to do other things while stuck in a loop. Is there anything like this in Motif, or even better, is there a timer event that I could set up to handle this function?
Thanks in advance!
Derek Brodeur
‹ XmText displays overwritten text Help with a Motif Widget Display Problem ›

dpeterc

Mon, 03/21/2005 - 19:25#1

Best way to poll the parallel port?

I have a similar situation in my program, just that I am pooling a serial port,
in an asynchronous way with low data rates.
I do not post the whole code, since it is too serial port specific, just a skeleton
so you can put your code in.

void signal_handler_IO(int status)
{
// printf("received SIGIO signal.\n");
dataWaiting=TRUE;
}

static void checkPortCB(XtPointer clientData)
{
/* do the reading and finish as soon as you can */
if (dataWaiting) /* dataWaiting is set by the signal handler, registred with serial port interface */
{
// read data
dataWaiting=FALSE;
}

/* register the same function again */
XtAddTimeOut(200, (XtTimerCallbackProc ) *checkPortCB, NULL);
}

main(...)
{
...
/* check for news again in 0.2 seconds */
XtAddTimeOut(200, (XtTimerCallbackProc ) *checkPortCB, NULL);
...
}