Read from /dev/lp, new patch against 2.1.27/28

Carsten Gross (carsten@sol.wohnheim.uni-ulm.de)
Sat, 8 Mar 1997 01:54:49 +0100 (MET)


Hello everyone...

I've enhanced the new "read" part of the printer driver. Now there is support
for nonblocking/blocking I/O, the timings are hopefully better (yes, i got
the documentation) and peripherals without "read" support are detected.
The complete "lp.c" file is available on:
http://www.wohnheim.uni-ulm.de/~carsten/lp.c
the diff against kernel version 2.1.27/28:
http://www.wohnheim.uni-ulm.de/~carsten/lp-2.1.27-diff.c
and the diff for the header file lp.h (just one line for the ioctl):
http://www.wohnheim.uni-ulm.de/~carsten/lp-2.1.27-diff.h

Some changes are: Read from a device that doesn't support status reads
returns always EIO (I/O Error). One read call returns one complete message
from the printer if possible. If no data is available the read blocks until
data is ready. It is possible to set O_NONBLOCK with fcntl to avoid blocking
(as you all know) and get EAGAIN. Unfortunality there is no support for the
interrupt driven driver at the moment. The read operation on lp returns
EINVAL in this case.

I've also added an ioctl. Now it is possible to read the name (called
"Device ID") of the attached device. The ioctl is called with ioctl(fd,
LPGETDEVICEID, char *buf). The buffer should be big enough to hold the
complete answer from the printer, otherwise you'll get EFAULT. The maximum
size of the answer is exactly 64K, but normally the answer is about 200 to
300 bytes. If you want to use the answer (this is a nice human readable
string) you've to access buf+2, because the first two bytes will contain the
length of the string in big endian.

It would be great if someone with a parallel port zip drive or another
"unusual" peripheral device attached to the printer port would like to test
this driver and especially the ioctl.

Carsten

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