source: trunk/third/lprng/doc/LPRng-HOWTO-3.html @ 14517

Revision 14517, 12.3 KB checked in by mwhitson, 25 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r14516, which included commits to RCS files with non-trunk default branches.
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2<HTML>
3<HEAD>
4 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
5 <TITLE> LPRng-HOWTO: Attaching Your Printer</TITLE>
6 <LINK HREF="LPRng-HOWTO-4.html" REL=next>
7 <LINK HREF="LPRng-HOWTO-2.html" REL=previous>
8 <LINK HREF="LPRng-HOWTO.html#toc3" REL=contents>
9</HEAD>
10<BODY>
11<A HREF="LPRng-HOWTO-4.html">Next</A>
12<A HREF="LPRng-HOWTO-2.html">Previous</A>
13<A HREF="LPRng-HOWTO.html#toc3">Contents</A>
14<HR>
15<H2><A NAME="installref"></A> <A NAME="s3">3. Attaching Your Printer</A></H2>
16
17<P>When installing a printer,
18the first step should be to make sure that the printer is actually
19working independently of the software.
20The following section outlines some simple diagnostics that you
21can use to check printer connectivity.
22<H2><A NAME="networkprinter"></A> <A NAME="ss3.1">3.1 Network Printers</A>
23</H2>
24
25<P>The most flexible and highest throughput printer interface is
26via a network (TCP/IP) connection.
27Most high performance printers have a built in network interface,
28or you can attach them to a
29<EM>printer server</EM>
30box which provides a network interface.
31Network print boxes can be obtained from
32Hewlett Packard
33(
34<A HREF="http://www.hp.com">http://www.hp.com</A>),
35Lantronix's
36(
37<A HREF="http://www.lantronix.com">http://www.lantronix.com</A>),
38and Rose Electronics
39(
40<A HREF="http://www.rosel.com">http://www.rosel.com</A>).
41<P>The network interface usually supports multiple network printing protocols.
42The most common are the LPD (RFC1179), Socket API, APPsocket, SMB,
43and Novell Netware interfaces.
44LPRng directly supports the LPD (RFC1179) and Socket API interfaces,
45and you can use the
46<CODE>smbclient</CODE> program from the
47<A HREF="LPRng-HOWTO-5.html#smb">Samba Software Package</A> for the SMB interface.
48There are no plans to support the Novell Netware interface,
49given the wide range of alternatives.
50<H3>Socket API</H3>
51
52<P>The most powerful network connection is via the the
53Socket API.
54The most common Socket API,
55and a <I>de facto</I> standard,
56is the one used by Hewlett Packard on their JetDirect cards,
57which allows a TCP/IP connection to port 9100.
58This is a TCP/IP port on the printer that provides
59a direct connection to the print engine,
60similar to a serial or parallel port.
61This connection is usually full duplex and provides error messages
62and status information during printing.
63<P>The Socket API is extremely simple.
64<OL>
65<LI>The user establishes a connection to port 9100.
66This connection may be refused if the printer is busy
67printing a job.</LI>
68<LI>Once the connection has been established,
69the print job is sent over the connection.
70During this transfer,
71error messages may be returned over the data link.</LI>
72<LI>After sending all the data,
73the sender should do a
74<I>half-close</I> of the connection.
75This tells the printer that no more data will be sent.</LI>
76<LI>After finishing printing the job,
77the printer will close the connection.</LI>
78</OL>
79<P>You can use the
80<A HREF="http://www.l0pht.com/~weld/netcat/">netcat</A>
81utility by Hobbit <CODE>&lt;Hobbit@avian.org&gt;</CODE>
82to test that this interface is available and working.
83If <I>ellipse.ps</I> is a test file, then:
84The simplest and easiest way to print a file to a network printer appears
85<BLOCKQUOTE><CODE>
86<PRE>
87  nc printer.ip.addr 9100 &lt; file
88Example:
89  nc 10.0.0.25 9100 &lt; ellipse.ps
90</PRE>
91</CODE></BLOCKQUOTE>
92<H3>LPD (RFC 1179) Protocol</H3>
93
94<P>The second most common network print protocol is the
95RFC1179 TCP/IP protocol.
96This is described in detail in later sections of this document,
97but basically consists of a
98simple set of command and responses.
99<OL>
100<LI>A connection is made to TCP/IP port 515 on the printer.
101As for the Socket API,
102this connection may fail if the printer is busy printing
103another job or has another network connection open.</LI>
104<LI>Once the connection has been established,
105a print request command is sent to the printer,
106and if printing is allowed
107an acknowledgment will be received.</LI>
108<LI>The files comprising the print job are sent to the printer.</LI>
109<LI>The connection to the printer is closed.</LI>
110</OL>
111<P>During the job transfer no error information is returned,
112or other status information.
113This must be obtained by reconnecting to the printer and sending
114a print status request.
115This is a major weakness of the RFC1179 protocol.
116<P>When the LPRng software package has been installed,
117it is easy to check printing by using a command of the form:
118<BLOCKQUOTE><CODE>
119<PRE>
120  lpr -Plp@ipaddr -Dnetwork file
121Example:
122  lpr -Plp@10.0.0.25 -Dnetwork ellipse.ps
123</PRE>
124</CODE></BLOCKQUOTE>
125<P>The <CODE>-Plp@ipaddr</CODE> option will cause the <CODE>lpr</CODE> program to make a direct
126connection to port 515  and send the print file using the RFC1179
127protocol.
128The <CODE>-Dnetwork</CODE> debugging option will cause detailed network status to be
129displayed during this process.
130<P>In addition to the <CODE>lpr</CODE> program,
131the Perl <CODE>cheap_lpr</CODE> program can be used.
132This and other test programs are in the LPRng Distribution <CODE>UTILS</CODE> directory.
133<H3><A NAME="appsocket"></A> APPsocket</H3>
134
135<P>The APPsocket interface is supported by Tektronix and some other printer
136vendors.
137It is similar to the Socket API,
138with a couple of minor differences.
139<OL>
140<LI>The printer has two ports for network connections:
141TCP port 9100 for TCP/IP stream connections and UDP port 9101 for UDP
142packet connections.</LI>
143<LI>When a 0 length UDP packet or a UDP packet containing only <CODE>CR/LF</CODE>
144is sent to UDP port 9101, the printer will return a packet to the sender
145containing print status information.
146This information indicates the printers current status (busy, idle, printing)
147and any error conditions.</LI>
148<LI>To send a job to the printer,
149a connection to port 9100 is made.
150This connection will be refused while the printer is busy or has a connection
151to another host.</LI>
152<LI>When the TCP connection is established,
153the job can be sent over the TCP stream.
154When all of the job has been transferred,
155the connection should be <I>shutdown</I> for sending data by the sender,
156but remain open to receive error messages or other information.</LI>
157<LI>An end or job indication in the data stream will also act to terminate
158the connection.
159This means that if the PostScript CTRL-D (end of job) character is sent in
160a job,  then the connection will be terminated.</LI>
161<LI>Once all the data has been received and the job has finished printing,
162the connection will be terminated by the printer.</LI>
163</OL>
164<P>The LPRng IFHP filter program has support for the APPsocket interface.
165Also,
166there are Perl or other programs which can communicate with the printer.
167See
168<A HREF="LPRng-HOWTO-5.html#P450">Tektronix P450 and Family</A> for details.
169<H2><A NAME="secnetwork"></A> <A NAME="ss3.2">3.2 Network Print Server Boxes</A>
170</H2>
171
172<P>A ``network print server'' is usually a box
173(external model) or card in a printer (internal model)
174which has a network connection to a TCP network and
175software to implement a LPD print server.
176If it is an external model,
177The parallel or serial port of
178the printer is connected to the box,
179and the print server may support multiple printers.
180If it is an internal model,
181the server is usually nothing more than a Network Interface Controller
182and a ROM containing software that the microprocessor in the printer
183uses.
184<P>The print server may support multiple printing protocols,
185such as
186<A HREF="LPRng-HOWTO-6.html#rfc1179">RFC1179</A>
187(TCP/IP printing using the LPD print protocol),
188Novell Printer Protocols,
189SMB print protocols,
190and AppleTalk protocols.
191One of the observed problems with Network Print servers is that while they
192can usually support one protocol and one user at a time quite well,
193when you try to use multiple protocols and/or multiple users try to transfer
194print jobs to the printer,  the printer may behave in a very odd manner.
195Usually this results in a printer failing to finish a job currently being
196printed,
197and unable to accept new jobs.
198<P>Several of the newer models of print servers have
199Simple Network Management Protocol (SNMP) agents built into them,
200and can provide detailed information about their internal functions.
201By using a SNMP manager such as SunNetmanage or HP-Openview,
202you can monitor your network printers activities.
203<P>I recommend that you use only a single protocol to send jobs to the printer.
204If you can,  I also recommend that you use a print spooler and have only
205a single host system send a job to the printer.
206<P>My best advice on connecting to network printers is not to use the
207the built-in LPD server,
208but to use the direct TCP/IP connection to the print engine.
209Usually this is done to particular TCP/IP port on the printer.
210For the HP JetDirect and other HP products, this is usually
211TCP port 9100.
212<P>Once you have the direct connection,
213you can now use various filters to preprocess the print job,
214insert PJL and PCL commands,
215or convert text to PostScript or PCL for better print quality.
216<P>
217<H2><A NAME="ss3.3">3.3 Parallel Printers</A>
218</H2>
219
220<P>In most UNIX systems the printer port has the name
221<CODE>/dev/lpt</CODE>,
222<CODE>/dev/prn</CODE>,
223or something similar.
224On most systems the
225<CODE>dmesg</CODE> utility will print a list of IO devices found
226during system configuration.
227Use the following commands to get the information and scan
228for the device.
229You should also make sure that the printer device is
230available.
231<BLOCKQUOTE><CODE>
232<PRE>
233dmesg >/tmp/a
234grep lp /tmp/a
235ls /dev/lp*
236</PRE>
237</CODE></BLOCKQUOTE>
238<P>
239<P>Gordon Haverland
240<CODE>&lt;haverlan@agric.gov.ab.ca</CODE>&gt; supplied this little script,
241that will assist with this:
242<BLOCKQUOTE><CODE>
243<PRE>
244#!/bin/sh
245#set -v -x              # uncomment for debugging
246PATH=/bin:/usr/bin
247printer=
248for printer in /dev/lp* ;
249do
250    echo PRINTER TEST to $printer 1&gt;&amp;2
251    for i in 1 2 3 4 5 6 7 8 9;
252    do
253        echo PRINTER $printer $i &gt; $printer;
254    done
255    echo -e \\r\\f &gt; $printer
256done
257exit 0;
258</PRE>
259</CODE></BLOCKQUOTE>
260<P>If your printer is connected to the device name you provided,
261then you should get a page of something out.  If the output
262suffers from the ``staircase'' effect, you will see the numbers
263``marching'' across the page, otherwise the numbers will all be in
264a single column.
265<H2><A NAME="secserial"></A> <A NAME="ss3.4">3.4 Serial Printers</A>
266</H2>
267
268<P>If your printer is attached by a serial line,
269then you may need to set the serial line characteristics before sending
270the job to the printer.
271Here are a set of guidelines to following when attaching a serial port printer
272to a serial line.
273<P>1. Check to make sure that the line is not enabled for login.
274Logins are usually managed by the
275<CODE>getty</CODE> (BSD)
276or
277<CODE>ttymon</CODE> (Solaris, SystemV).
278Check your system documentation and make sure that these daemons are not
279managing the serial line.
280<P>2. Check the permissions and ownership of the serial line.
281For the most easy testing,
282set the permissions to 0666 (everybody can open for reading and writing).
283After you have made sure that you can send jobs to the printer,
284you might want to change the ownership of the serial line to the LPD server
285and change the permissions to 0600.
286<P>3. Make sure that you can print a test file on the printer via the
287serial port.
288This may require setting the line characteristics and then sending
289a file to the printer.
290You should try to use 8 bit, no parity, with hardware flow control
291and no special character interpretation,
292and definitely no LF to CR/LF translation.
293The problem is that different versions of UNIX systems have different
294sets of stty(1) commands to do this.
295The following simple test script can help in this.
296<BLOCKQUOTE><CODE>
297<PRE>
298#!/bin/sh
299# 9600, no echo, no CR
300FLAGS= 9600 -raw -parenb cs8 crtscts
301DEV= /dev/tty01
302(stty $FLAGS; stty 1>&amp;2; cat $1 ) &lt;$DEV >$DEV
303</PRE>
304</CODE></BLOCKQUOTE>
305<P>This shows using stty to set the flags,
306then to print the current settings, and then using
307cat a file to the output.
308If you attach a dumb terminal to the serial port,
309you can even use this script to ensure that input from the device
310is echoed to the output with the correct speed, parity,
311etc.
312<P>Experience has shown that serially connected printers are the least
313reliable and lowest speed.
314Where possible,
315it is strongly recommended that they be attached to a <I>network print box</I>
316which will provide a
317Socket API interface and handle the low level network to serial port protocol
318conversions.
319<HR>
320<A HREF="LPRng-HOWTO-4.html">Next</A>
321<A HREF="LPRng-HOWTO-2.html">Previous</A>
322<A HREF="LPRng-HOWTO.html#toc3">Contents</A>
323</BODY>
324</HTML>
Note: See TracBrowser for help on using the repository browser.