⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printing-intro-setup.html

📁 这是很好的学习嵌入式LINUX的文章
💻 HTML
📖 第 1 页 / 共 4 页
字号:
spooling directory with the <var class="LITERAL">sd</var> capability:</p><pre class="PROGRAMLISTING">##  /etc/printcap for host rose - added spooling directories#rattan|line|diablo|lp|Diablo 630 Line Printer:\        :sh:sd=/var/spool/lpd/rattan:bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\        :sh:sd=/var/spool/lpd/bamboo:</pre><p>Note that the name of the printer starts in the first column but all other entriesdescribing the printer should be indented with a tab and each line escaped with abackslash.</p><p>If you do not specify a spooling directory with <var class="LITERAL">sd</var>, thespooling system will use <tt class="FILENAME">/var/spool/lpd</tt> as a default.</p></div><div class="SECT4"><h4 class="SECT4"><a id="PRINTING-DEVICE" name="PRINTING-DEVICE">9.3.1.4.4. Identifyingthe Printer Device</a></h4><p>In the <a href="printing-intro-setup.html#PRINTING-DEV-PORTS">Adding <ttclass="FILENAME">/dev</tt> Entries for the Ports</a> section, we identified which entryin the <tt class="FILENAME">/dev</tt> directory FreeBSD will use to communicate with theprinter. Now, we tell <b class="APPLICATION">LPD</b> that information. When the spoolingsystem has a job to print, it will open the specified device on behalf of the filterprogram (which is responsible for passing data to the printer).</p><p>List the <tt class="FILENAME">/dev</tt> entry pathname in the <ttclass="FILENAME">/etc/printcap</tt> file using the <var class="LITERAL">lp</var>capability.</p><p>In our running example, let us assume that <var class="LITERAL">rattan</var> is on thefirst parallel port, and <var class="LITERAL">bamboo</var> is on a sixth serial port;here are the additions to <tt class="FILENAME">/etc/printcap</tt>:</p><pre class="PROGRAMLISTING">##  /etc/printcap for host rose - identified what devices to use#rattan|line|diablo|lp|Diablo 630 Line Printer:\        :sh:sd=/var/spool/lpd/rattan:\        :lp=/dev/lpt0:bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\        :sh:sd=/var/spool/lpd/bamboo:\        :lp=/dev/ttyd5:</pre><p>If you do not specify the <var class="LITERAL">lp</var> capability for a printer inyour <tt class="FILENAME">/etc/printcap</tt> file, <b class="APPLICATION">LPD</b> uses<tt class="FILENAME">/dev/lp</tt> as a default. <tt class="FILENAME">/dev/lp</tt>currently does not exist in FreeBSD.</p><p>If the printer you are installing is connected to a parallel port, skip to the sectionentitled, <a href="printing-intro-setup.html#PRINTING-TEXTFILTER">Installing the TextFilter</a>. Otherwise, be sure to follow the instructions in the next section.</p></div><div class="SECT4"><h4 class="SECT4"><a id="PRINTING-COMMPARAM" name="PRINTING-COMMPARAM">9.3.1.4.5.Configuring Spooler Communication Parameters</a></h4><p>For printers on serial ports, <b class="APPLICATION">LPD</b> can set up the bps rate,parity, and other serial communication parameters on behalf of the filter program thatsends data to the printer. This is advantageous since:</p><ul><li><p>It lets you try different communication parameters by simply editing the <ttclass="FILENAME">/etc/printcap</tt> file; you do not have to recompile the filterprogram.</p></li><li><p>It enables the spooling system to use the same filter program for multiple printerswhich may have different serial communication settings.</p></li></ul><p>The following <tt class="FILENAME">/etc/printcap</tt> capabilities control serialcommunication parameters of the device listed in the <var class="LITERAL">lp</var>capability:</p><div class="VARIABLELIST"><dl><dt><var class="LITERAL">br#<var class="REPLACEABLE">bps-rate</var></var></dt><dd><p>Sets the communications speed of the device to <varclass="REPLACEABLE">bps-rate</var>, where <var class="REPLACEABLE">bps-rate</var> can be50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600,or 115200 bits-per-second.</p></dd><dt><var class="LITERAL">ms#<var class="REPLACEABLE">stty-mode</var></var></dt><dd><p>Sets the options for the terminal device after opening the device. <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">stty</span>(1)</span> explains theavailable options.</p></dd></dl></div><p>When <b class="APPLICATION">LPD</b> opens the device specified by the <varclass="LITERAL">lp</var> capability, it sets the characteristics of the device to thosespecified with the <var class="LITERAL">ms#</var> capability. Of particular interest willbe the <var class="LITERAL">parenb</var>, <var class="LITERAL">parodd</var>, <varclass="LITERAL">cs5</var>, <var class="LITERAL">cs6</var>, <varclass="LITERAL">cs7</var>, <var class="LITERAL">cs8</var>, <varclass="LITERAL">cstopb</var>, <var class="LITERAL">crtscts</var>, and <varclass="LITERAL">ixon</var> modes, which are explained in the <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">stty</span>(1)</span> manual page.</p><p>Let us add to our example printer on the sixth serial port. We will set the bps rateto 38400. For the mode, we will set no parity with <var class="LITERAL">-parenb</var>,8-bit characters with <var class="LITERAL">cs8</var>, no modem control with <varclass="LITERAL">clocal</var> and hardware flow control with <varclass="LITERAL">crtscts</var>:</p><pre class="PROGRAMLISTING">bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\        :sh:sd=/var/spool/lpd/bamboo:\        :lp=/dev/ttyd5:ms#-parenb cs8 clocal crtscts:</pre></div><div class="SECT4"><h4 class="SECT4"><a id="PRINTING-TEXTFILTER" name="PRINTING-TEXTFILTER">9.3.1.4.6.Installing the Text Filter</a></h4><p>We are now ready to tell <b class="APPLICATION">LPD</b> what text filter to use tosend jobs to the printer. A <span class="emphasis"><i class="EMPHASIS">textfilter</i></span>, also known as an <span class="emphasis"><i class="EMPHASIS">inputfilter</i></span>, is a program that <b class="APPLICATION">LPD</b> runs when it has ajob to print. When <b class="APPLICATION">LPD</b> runs the text filter for a printer, itsets the filter's standard input to the job to print, and its standard output to theprinter device specified with the <var class="LITERAL">lp</var> capability. The filter isexpected to read the job from standard input, perform any necessary translation for theprinter, and write the results to standard output, which will get printed. For moreinformation on the text filter, see the <ahref="printing-advanced.html#PRINTING-ADVANCED-FILTERS">Filters</a> section.</p><p>For our simple printer setup, the text filter can be a small shell script that justexecutes <tt class="COMMAND">/bin/cat</tt> to send the job to the printer. FreeBSD comeswith another filter called <tt class="FILENAME">lpf</tt> that handles backspacing andunderlining for printers that might not deal with such character streams well. And, ofcourse, you can use any other filter program you want. The filter <ttclass="COMMAND">lpf</tt> is described in detail in section entitled <ahref="printing-advanced.html#PRINTING-ADVANCED-LPF">lpf: a Text Filter</a>.</p><p>First, let us make the shell script <ttclass="FILENAME">/usr/local/libexec/if-simple</tt> be a simple text filter. Put thefollowing text into that file with your favorite text editor:</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./bin/cat &amp;&amp; exit 0exit 2</pre><p>Make the file executable:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">chmod 555 /usr/local/libexec/if-simple</kbd></pre><p>And then tell LPD to use it by specifying it with the <var class="LITERAL">if</var>capability in <tt class="FILENAME">/etc/printcap</tt>. We will add it to the two printerswe have so far in the example <tt class="FILENAME">/etc/printcap</tt>:</p><pre class="PROGRAMLISTING">##  /etc/printcap for host rose - added text filter#rattan|line|diablo|lp|Diablo 630 Line Printer:\        :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\        :if=/usr/local/libexec/if-simple:bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\        :sh:sd=/var/spool/lpd/bamboo:\        :lp=/dev/ttyd5:ms#-parenb cs8 clocal crtscts:\        :if=/usr/local/libexec/if-simple:</pre><div class="NOTE"><blockquote class="NOTE"><p><b>注:</b> A copy of the <tt class="FILENAME">if-simple</tt> script can be found inthe <tt class="FILENAME">/usr/share/examples/printing</tt> directory.</p></blockquote></div></div><div class="SECT4"><h4 class="SECT4"><a id="AEN11016" name="AEN11016">9.3.1.4.7. Turn on <bclass="APPLICATION">LPD</b></a></h4><p><span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpd</span>(8)</span> is runfrom <tt class="FILENAME">/etc/rc</tt>, controlled by the <varclass="LITERAL">lpd_enable</var> variable. This variable defaults to <varclass="LITERAL">NO</var>. If you have not done so already, add the line:</p><pre class="PROGRAMLISTING">lpd_enable="YES"</pre><p>to <tt class="FILENAME">/etc/rc.conf</tt>, and then either restart your machine, orjust run <span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpd</span>(8)</span>.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">lpd</kbd></pre></div><div class="SECT4"><h4 class="SECT4"><a id="PRINTING-TRYING" name="PRINTING-TRYING">9.3.1.4.8. Trying ItOut</a></h4><p>You have reached the end of the simple <b class="APPLICATION">LPD</b> setup.Unfortunately, congratulations are not quite yet in order, since we still have to testthe setup and correct any problems. To test the setup, try printing something. To printwith the <b class="APPLICATION">LPD</b> system, you use the command <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span>, which submits ajob for printing.</p><p>You can combine <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lpr</span>(1)</span> with the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lptest</span>(1)</span> program, introduced in section <ahref="printing-intro-setup.html#PRINTING-TESTING">Checking Printer Communications</a> togenerate some test text.</p><p><span class="emphasis"><i class="EMPHASIS">To test the simple <bclass="APPLICATION">LPD</b> setup:</i></span></p><p>Type:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">lptest 20 5 | lpr -P<varclass="REPLACEABLE">printer-name</var></kbd></pre><p>Where <var class="REPLACEABLE">printer-name</var> is a the name of a printer (or analias) specified in <tt class="FILENAME">/etc/printcap</tt>. To test the default printer,type <span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span> withoutany <var class="OPTION">-P</var> argument. Again, if you are testing a printer thatexpects <span class="TRADEMARK">PostScript</span>, send a <spanclass="TRADEMARK">PostScript</span> program in that language instead of using <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lptest</span>(1)</span>. You can do soby putting the program in a file and typing <tt class="COMMAND">lpr <varclass="REPLACEABLE">file</var></tt>.</p><p>For a <span class="TRADEMARK">PostScript</span> printer, you should get the results ofthe program. If you are using <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lptest</span>(1)</span>, then your results should look like thefollowing:</p><pre class="PROGRAMLISTING">!"#$%&amp;'()*+,-./01234"#$%&amp;'()*+,-./012345#$%&amp;'()*+,-./0123456$%&amp;'()*+,-./01234567%&amp;'()*+,-./012345678</pre><p>To further test the printer, try downloading larger programs (for language-basedprinters) or running <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lptest</span>(1)</span> with different arguments. For example, <ttclass="COMMAND">lptest 80 60</tt> will produce 60 lines of 80 characters each.</p><p>If the printer did not work, see the <ahref="printing-troubleshooting.html">Troubleshooting</a> section.</p></div></div></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-intro-spooler.html"accesskey="P">后退</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">起点</a></td><td width="33%" align="right" valign="top"><a href="printing-advanced.html"accesskey="N">前进</a></td></tr><tr><td width="33%" align="left" valign="top">介绍</td><td width="34%" align="center" valign="top"><a href="printing.html"accesskey="U">上一级</a></td><td width="33%" align="right" valign="top">Advanced Printer Setup</td></tr></table></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -