<HTML ><HEAD ><TITLE >Serial printers under lpd</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" HREF="t1.htm"><LINK REL="PREVIOUS" TITLE="On-screen previewing of printable things." HREF="x2187.htm"><LINK REL="NEXT" TITLE="What's missing?" HREF="x2282.htm"></HEAD ><BODY CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" ></TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="x2187.htm" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="x2282.htm" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="serial" ></A >Serial printers under lpd</H1 ><A NAME="AEN2234" ></A ><P >Serial printers are rather tricky under lpd.</P ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="serial-printcap" ></A >Setting up in printcap</H2 ><P >Lpd provides five attributes which you can set in<SPAN CLASS="emphasis" ><I CLASS="emphasis" >/etc/printcap</I ></SPAN > to control all the settings of the serial port a printer is on. Read the <SPAN CLASS="emphasis" ><I CLASS="emphasis" ><A HREF="http://www.linuxprinting.org/man/printcap.5.html" TARGET="_top" >printcap</A ></I ></SPAN > man page and note the meanings of<SPAN CLASS="emphasis" ><I CLASS="emphasis" >br#</I ></SPAN >, <SPAN CLASS="emphasis" ><I CLASS="emphasis" >fc#</I ></SPAN >,<SPAN CLASS="emphasis" ><I CLASS="emphasis" >xc#</I ></SPAN >, <SPAN CLASS="emphasis" ><I CLASS="emphasis" >fs#</I ></SPAN > and<SPAN CLASS="emphasis" ><I CLASS="emphasis" >xs#</I ></SPAN >. The last four of these attributes are bitmaps indicating the settings for use the port. The<SPAN CLASS="emphasis" ><I CLASS="emphasis" >br#</I ></SPAN > attribute is simply the baud rate, eg `<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 `<SPAN CLASS="emphasis" ><I CLASS="emphasis" >stty -a</I ></SPAN >' looks like for my printer port:<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 > 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 `<SPAN CLASS="emphasis" ><I CLASS="emphasis" >cat file > /dev/ttyS2</I ></SPAN >' (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 > <PRE CLASS="screen" >/* c_cflag bit meaning */ #define CBAUD 0000017</PRE >This section lists the meaning of the <SPAN CLASS="emphasis" ><I CLASS="emphasis" >fc#</I ></SPAN > and <SPAN CLASS="emphasis" ><I CLASS="emphasis" >fs#</I ></SPAN > 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<SPAN CLASS="emphasis" ><I CLASS="emphasis" >fc#</I ></SPAN > 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 <SPAN CLASS="emphasis" ><I CLASS="emphasis" >fs#</I ></SPAN > 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="AEN2276" ></A >Older serial printers that drop characters</H2 ><P >Jon Luckey points out that some older serial printers with ten-cent serial interfaces and small buffers<SPAN CLASS="emphasis" ><I CLASS="emphasis" >really</I ></SPAN > 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 SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="x2187.htm" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="t1.htm" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="x2282.htm" ACCESSKEY="N" >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 >