Serial printers are rather tricky under lpd.
Lpd provides five attributes which you can set in/etc/printcap to control all the settings of
the serial port a printer is on. Read the printcap man page and note the meanings ofbr#, fc#,xc#, fs# andxs#. The last four of these attributes
are bitmaps indicating the settings for use the port. Thebr# attribute is simply the baud rate, eg
`br#9600
'.
It is very easy to translate from stty settings to printcap flag settings. If you need to, see the man page for stty now.
Use stty to set up the printer port so that you can cat a file to it and have it print correctly. Here's what `stty -a' looks like for my printer port:
dina:/usr/users/andy/work/lpd/lpd# stty -a < /dev/ttyS2 speed 9600 baud; rows 0; columns 0; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; min = 1; time = 0; -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff -iuclc -ixany -imaxbel -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke
The only changes between this and the way the port is initialized
at bootup are -clocal
, -crtscts
, and ixon
. Your port may well be different
depending on how your printer does flow control.
You actually use stty in a somewhat odd way. Since stty operates
on the terminal connected to it's standard input, you use it to
manipulate a given serial port by using the `<
' character as above.
Once you have your stty settings right, so that `cat file > /dev/ttyS2' (in my case) sends the file to the printer, look at the file /usr/src/linux/include/asm-i386/termbits.h. This contains a lot of #defines and a few structs (You may wish to cat this file to the printer (you do have that working, right?) and use it as scratch paper). Go to the section that starts out
/* c_cflag bit meaning */ #define CBAUD 0000017
This section lists the meaning of the fc# and fs# bits. You will notice that the names there (after the baud rates) match up with one of the lines of stty output. Didn't I say this was going to be easy?
Note which of those settings are preceded with a - in your stty
output. Sum up all those numbers (they are octal). This represents
the bits you want to clear, so the result is yourfc# capability. Of course, remember that
you will be setting bits directly after you clear, so you can just
use `fc#0177777
' (I do).
Now do the same for those settings (listed in this section) which
do not have a - before them in your stty output. In my example the
important ones are CS8 (0000060), HUPCL (0002000), and CREAD
(0000200). Also note the flags for your baud rate (mine is
0000015). Add those all up, and in my example you get
0002275. This goes in your fs# capability
(`fs#02275
' works fine in my
example).
Do the same with set and clear for the next section of the include
file, "c_lflag bits". In my case I didn't have to set
anything, so I just use `xc#0157777
' and `xs#0
'.
Jon Luckey points out that some older serial printers with
ten-cent serial interfaces and small buffersreally mean stop when they say so with flow
control. He found that disabling the FIFO in his Linux box's
16550 serial port with setserial
corrected the problem of dropped
characters (you apparently just specify the UART type as an 8250
to do this).