<HTML ><HEAD ><TITLE >Serial printers under lpd</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.49"><LINK REL="HOME" TITLE="The Printing HOWTO" HREF="index.html"><LINK REL="PREVIOUS" TITLE="On-screen previewing of printable things." HREF="previewing.html"><LINK REL="NEXT" TITLE="What's missing?" HREF="development.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >The Printing HOWTO</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="previewing.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="development.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="SERIAL" >17. Serial printers under lpd</A ></H1 ><A NAME="AEN2870" ></A ><P > Serial printers are rather tricky under lpd. </P ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="SERIAL-PRINTCAP" >17.1. Setting up in printcap</A ></H2 ><P > Lpd provides five attributes which you can set in <I CLASS="EMPHASIS" >/etc/printcap</I > to control all the settings of the serial port a printer is on. Read the <I CLASS="EMPHASIS" ><A HREF="http://www.linuxprinting.org/man/printcap.5.html" TARGET="_top" >printcap</A ></I > man page and note the meanings of <I CLASS="EMPHASIS" >br#</I >, <I CLASS="EMPHASIS" >fc#</I >, <I CLASS="EMPHASIS" >xc#</I >, <I CLASS="EMPHASIS" >fs#</I > and <I CLASS="EMPHASIS" >xs#</I >. The last four of these attributes are bitmaps indicating the settings for use the port. The <I CLASS="EMPHASIS" >br#</I > atrribute is simply the baud rate, ie `<TT CLASS="LITERAL" >br#9600</TT >'. </P ><P > It is very easy to translate from <A HREF="http://www.linuxprinting.org/man/stty.1.html" TARGET="_top" >stty</A > settings to printcap flag settings. If you need to, see the man page for stty now. </P ><P > 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 `<I CLASS="EMPHASIS" >stty -a</I >' looks like for my printer port: <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" >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</PRE ></TD ></TR ></TABLE > The only changes between this and the way the port is initialized at bootup are <TT CLASS="LITERAL" >-clocal</TT >, <TT CLASS="LITERAL" >-crtscts</TT >, and <TT CLASS="LITERAL" >ixon</TT >. Your port may well be different depending on how your printer does flow control. </P ><P > 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 `<TT CLASS="LITERAL" ><</TT >' character as above. </P ><P > Once you have your stty settings right, so that `<I CLASS="EMPHASIS" >cat file > /dev/ttyS2</I >' (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 </P ><P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" >/* c_cflag bit meaning */ #define CBAUD 0000017</PRE ></TD ></TR ></TABLE > This section lists the meaning of the <I CLASS="EMPHASIS" >fc#</I > and <I CLASS="EMPHASIS" >fs#</I > 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? </P ><P > 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 your <I CLASS="EMPHASIS" >fc#</I > capability. Of course, remember that you will be setting bits directly after you clear, so you can just use `<TT CLASS="LITERAL" >fc#0177777</TT >' (I do). </P ><P > 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 <I CLASS="EMPHASIS" >fs#</I > capability (`<TT CLASS="LITERAL" >fs#02275</TT >' works fine in my example). </P ><P > 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 `<TT CLASS="LITERAL" >xc#0157777</TT >' and `<TT CLASS="LITERAL" >xs#0</TT >'. </P ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN2913" >17.2. Older serial printers that drop characters</A ></H2 ><P > Jon Luckey points out that some older serial printers with ten-cent serial interfaces and small buffers <I CLASS="EMPHASIS" >really</I > mean stop when they say so with flow control. He found that disabling the FIFO in his Linux box's 16550 serial port with <TT CLASS="LITERAL" ><A HREF="http://www.linuxprinting.org/man/setserial.8.html" TARGET="_top" >setserial</A ></TT > corrected the problem of dropped characters (you apparently just specify the uart type as an 8250 to do this). </P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="previewing.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="development.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >On-screen previewing of printable things.</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >What's missing?</TD ></TR ></TABLE ></DIV ></BODY ></HTML >