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