Re: parport patch / lp_readback

Carsten Gross (carsten@sol.wohnheim.uni-ulm.de)
Wed, 23 Apr 1997 16:17:29 +0200 (MET DST)


Martin Buck wrote:
> This is the only useful solution if you want to write a daemon that sits in
> the background and monitors the status of a printer (e.g. to display the
> status panel that HP omitted on their newer printers on the screen).
> Otherwise you'd have to use polling...
The problem with the printer device (at the moment) is that you can open it
once, not twice or multiple times. The best way for a status monitor or
whatever is to use a modified printer daemon like LPRng. This daemon handles
all reads and writes from and to lp. The code for the "blocking IO" is not
perfect, but without interrupts you've to poll. But lets have a look at it:

do { /* printer has no data for reading, "not ready" */
lp_read_terminate(minor);
if (file->f_flags & O_NONBLOCK)
return -EAGAIN;
if (current->signal & ~current->blocked)
return -EINTR;
current->state=TASK_INTERRUPTIBLE;
current->timeout=jiffies+1;
schedule();
retval=parport_ieee1284_nibble_mode_ok\
(lp_table[minor].dev->port, 0);
} while (retval == 2);

As you see, we are polling inside the driver, but this is the only
possiblity to wait without interrupt configured.

> Does select() work on the lp device? This would be a nice alternative to
> nonblocking IO.
Unfortunality select() is not implemented (yet :) ). This would be very nice,
indeed.

Ciao

Carsten

-- 
Carsten Gross		Internet: carsten@sol.wohnheim.uni-ulm.de
Wohnheim Heilmeyersteige:  Sebastian Kneipp Weg 6, 89075 Ulm