📄 printing-troubleshooting.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Troubleshooting</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Printing" href="printing.html" /><link rel="PREVIOUS" title="Alternatives to the Standard Spooler"href="printing-lpd-alternatives.html" /><link rel="NEXT" title="Linux Binary Compatibility" href="linuxemu.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></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">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="printing-lpd-alternatives.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 9 Printing</td><td width="10%" align="right" valign="bottom"><a href="linuxemu.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="PRINTING-TROUBLESHOOTING" name="PRINTING-TROUBLESHOOTING">9.7Troubleshooting</a></h1><p>After performing the simple test with <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lptest&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lptest</span>(1)</span></a>, you mighthave gotten one of the following results instead of the correct printout:</p><div class="VARIABLELIST"><dl><dt>It worked, after awhile; or, it did not eject a full sheet.</dt><dd><p>The printer printed the above, but it sat for awhile and did nothing. In fact, youmight have needed to press a PRINT REMAINING or FORM FEED button on the printer to getany results to appear.</p><p>If this is the case, the printer was probably waiting to see if there was any moredata for your job before it printed anything. To fix this problem, you can have the textfilter send a FORM FEED character (or whatever is necessary) to the printer. This isusually sufficient to have the printer immediately print any text remaining in itsinternal buffer. It is also useful to make sure each print job ends on a full sheet, sothe next job does not start somewhere on the middle of the last page of the previousjob.</p><p>The following replacement for the shell script <ttclass="FILENAME">/usr/local/libexec/if-simple</tt> prints a form feed after it sends thejob to the printer:</p><pre class="PROGRAMLISTING">#!/bin/sh## if-simple - Simple text input filter for lpd# Installed in /usr/local/libexec/if-simple## Simply copies stdin to stdout. Ignores all filter arguments.# Writes a form feed character (\f) after printing job./bin/cat && printf "\f" && exit 0exit 2</pre></dd><dt>It produced the ``staircase effect.''</dt><dd><p>You got the following on paper:</p><pre class="PROGRAMLISTING">!"#$%&'()*+,-./01234 "#$%&'()*+,-./012345 #$%&'()*+,-./0123456</pre><p>You have become another victim of the <span class="emphasis"><iclass="EMPHASIS">staircase effect</i></span>, caused by conflicting interpretations ofwhat characters should indicate a new line. <span class="TRADEMARK">UNIX</span>®style operating systems use a single character: ASCII code 10, the line feed (LF). <spanclass="TRADEMARK">MS-DOS</span>®, <span class="TRADEMARK">OS/2</span>®, andothers uses a pair of characters, ASCII code 10 <span class="emphasis"><iclass="EMPHASIS">and</i></span> ASCII code 13 (the carriage return or CR). Many printersuse the <span class="TRADEMARK">MS-DOS</span> convention for representing new-lines.</p><p>When you print with FreeBSD, your text used just the line feed character. The printer,upon seeing a line feed character, advanced the paper one line, but maintained the samehorizontal position on the page for the next character to print. That is what thecarriage return is for: to move the location of the next character to print to the leftedge of the paper.</p><p>Here is what FreeBSD wants your printer to do:</p><div class="INFORMALTABLE"><a id="AEN12925" name="AEN12925"></a><table border="0" frame="void" class="CALSTABLE"><col /><col /><tbody><tr><td>Printer received CR</td><td>Printer prints CR</td></tr><tr><td>Printer received LF</td><td>Printer prints CR + LF</td></tr></tbody></table></div><p>Here are some ways to achieve this:</p><ul><li><p>Use the printer's configuration switches or control panel to alter its interpretationof these characters. Check your printer's manual to find out how to do this.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> If you boot your system into other operating systems besides FreeBSD, youmay have to <span class="emphasis"><i class="EMPHASIS">reconfigure</i></span> the printerto use a an interpretation for CR and LF characters that those other operating systemsuse. You might prefer one of the other solutions, below.</p></blockquote></div></li><li><p>Have FreeBSD's serial line driver automatically convert LF to CR+LF. Of course, thisworks with printers on serial ports <span class="emphasis"><iclass="EMPHASIS">only</i></span>. To enable this feature, use the <varclass="LITERAL">ms#</var> capability and set the <var class="LITERAL">onlcr</var> mode inthe <tt class="FILENAME">/etc/printcap</tt> file for the printer.</p></li><li><p>Send an <span class="emphasis"><i class="EMPHASIS">escape code</i></span> to theprinter to have it temporarily treat LF characters differently. Consult your printer'smanual for escape codes that your printer might support. When you find the proper escapecode, modify the text filter to send the code first, then send the print job.</p><p>Here is an example text filter for printers that understand the Hewlett-Packard PCLescape codes. This filter makes the printer treat LF characters as a LF and CR; then itsends the job; then it sends a form feed to eject the last page of the job. It shouldwork with nearly all Hewlett Packard printers.</p><pre class="PROGRAMLISTING">#!/bin/sh## hpif - Simple text input filter for lpd for HP-PCL based printers# Installed in /usr/local/libexec/hpif## Simply copies stdin to stdout. Ignores all filter arguments.# Tells printer to treat LF as CR+LF. Ejects the page when done.printf "\033&k2G" && cat && printf "\033&l0H" && exit 0exit 2</pre><p>Here is an example <tt class="FILENAME">/etc/printcap</tt> from a host called <ttclass="HOSTID">orchid</tt>. It has a single printer attached to its first parallel port,a Hewlett Packard LaserJet 3Si named <var class="LITERAL">teak</var>. It is using theabove script as its text filter:</p><pre class="PROGRAMLISTING">## /etc/printcap for host orchid#teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ :if=/usr/local/libexec/hpif:</pre></li></ul></dd><dt>It overprinted each line.</dt><dd><p>The printer never advanced a line. All of the lines of text were printed on top ofeach other on one line.</p><p>This problem is the ``opposite'' of the staircase effect, described above, and is muchrarer. Somewhere, the LF characters that FreeBSD uses to end a line are being treated asCR characters to return the print location to the left edge of the paper, but not alsodown a line.</p><p>Use the printer's configuration switches or control panel to enforce the followinginterpretation of LF and CR characters:</p><div class="INFORMALTABLE"><a id="AEN12966" name="AEN12966"></a><table border="0" frame="void" class="CALSTABLE"><col /><col /><thead><tr><th>Printer receives</th><th>Printer prints</th></tr></thead><tbody><tr><td>CR</td><td>CR</td></tr><tr><td>LF</td><td>CR + LF</td></tr></tbody></table></div></dd><dt>The printer lost characters.</dt><dd><p>While printing, the printer did not print a few characters in each line. The problemmight have gotten worse as the printer ran, losing more and more characters.</p><p>The problem is that the printer cannot keep up with the speed at which the computersends data over a serial line (this problem should not occur with printers on parallelports). There are two ways to overcome the problem:</p><ul><li><p>If the printer supports XON/XOFF flow control, have FreeBSD use it by specifying the<var class="LITERAL">ixon</var> mode in the <var class="LITERAL">ms#</var>capability.</p></li><li><p>If the printer supports carrier flow control, specify the <varclass="LITERAL">crtscts</var> mode in the <var class="LITERAL">ms#</var> capability. Makesure the cable connecting the printer to the computer is correctly wired for carrier flowcontrol.</p></li></ul></dd><dt>It printed garbage.</dt><dd><p>The printer printed what appeared to be random garbage, but not the desired text.</p><p>This is usually another symptom of incorrect communications parameters with a serialprinter. Double-check the bps rate in the <var class="LITERAL">br</var> capability, andthe parity setting in the <var class="LITERAL">ms#</var> capability; make sure theprinter is using the same settings as specified in the <ttclass="FILENAME">/etc/printcap</tt> file.</p></dd><dt>Nothing happened.</dt><dd><p>If nothing happened, the problem is probably within FreeBSD and not the hardware. Addthe log file (<var class="LITERAL">lf</var>) capability to the entry for the printer youare debugging in the <tt class="FILENAME">/etc/printcap</tt> file. For example, here isthe entry for <var class="LITERAL">rattan</var>, with the <var class="LITERAL">lf</var>capability:</p><pre class="PROGRAMLISTING">rattan|line|diablo|lp|Diablo 630 Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple:\ :lf=/var/log/rattan.log</pre><p>Then, try printing again. Check the log file (in our example, <ttclass="FILENAME">/var/log/rattan.log</tt>) to see any error messages that might appear.Based on the messages you see, try to correct the problem.</p><p>If you do not specify a <var class="LITERAL">lf</var> capability, <bclass="APPLICATION">LPD</b> uses <tt class="FILENAME">/dev/console</tt> as a default.</p></dd></dl></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="printing-lpd-alternatives.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="linuxemu.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Alternatives to the Standard Spooler</td><td width="34%" align="center" valign="top"><a href="printing.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Linux Binary Compatibility</td></tr></table></div><p align="center"><small>This, and other documents, can be downloaded from <ahref="ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/">ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/</a>.</small></p><p align="center"><small>For questions about FreeBSD, read the <ahref="http://www.FreeBSD.org/docs.html">documentation</a> before contacting <<ahref="mailto:questions@FreeBSD.org">questions@FreeBSD.org</a>>.<br />For questions about this documentation, e-mail <<ahref="mailto:doc@FreeBSD.org">doc@FreeBSD.org</a>>.</small></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -