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

📄 printing-intro-setup.html

📁 这是很好的学习嵌入式LINUX的文章
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<p><b>注:</b> FreeBSD&nbsp;5.0 includes the <var class="LITERAL">devfs</var> filesystemwhich automatically creates device nodes as needed. If you are running a version ofFreeBSD with <var class="LITERAL">devfs</var> enabled then you can safely skip thissection.</p></blockquote></div><p>Even though the kernel may support communication along a serial or parallel port, youwill still need a software interface through which programs running on the system cansend and receive data. That is what entries in the <tt class="FILENAME">/dev</tt>directory are for.</p><p><span class="emphasis"><i class="EMPHASIS">To add a <tt class="FILENAME">/dev</tt>entry for a port:</i></span></p><div class="PROCEDURE"><ol type="1"><li><p>Become <tt class="USERNAME">root</tt> with the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">su</span>(1)</span> command. Enter the <ttclass="USERNAME">root</tt> password when prompted.</p></li><li><p>Change to the <tt class="FILENAME">/dev</tt> directory:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /dev</kbd></pre></li><li><p>Type:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">./MAKEDEV <varclass="REPLACEABLE">port</var></kbd></pre><p>Where <var class="REPLACEABLE">port</var> is the device entry for the port you want tomake. Use <var class="LITERAL">lpt0</var> for the printer on the first parallel port,<var class="LITERAL">lpt1</var> for the printer on the second port, and so on; use <varclass="LITERAL">ttyd0</var> for the first serial port, <var class="LITERAL">ttyd1</var>for the second, and so on.</p></li><li><p>Type:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ls -l <varclass="REPLACEABLE">port</var></kbd></pre><p>to make sure the device entry got created.</p></li></ol></div><div class="SECT4"><h4 class="SECT4"><a id="PRINTING-PARALLEL-PORT-MODE"name="PRINTING-PARALLEL-PORT-MODE">9.3.1.3.1. Setting the Communication Mode for theParallel Port</a></h4><p>When you are using the parallel interface, you can choose whether FreeBSD should useinterrupt-driven or polled communication with the printer. The generic printer devicedriver (<span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpt</span>(4)</span>) onFreeBSD&nbsp;4.X and 5.X uses the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">ppbus</span>(4)</span> system, which controls the port chipset withthe <span class="CITEREFENTRY"><span class="REFENTRYTITLE">ppc</span>(4)</span>driver.</p><ul><li><p>The <span class="emphasis"><i class="EMPHASIS">interrupt-driven</i></span> method isthe default with the GENERIC kernel. With this method, the operating system uses an IRQline to determine when the printer is ready for data.</p></li><li><p>The <span class="emphasis"><i class="EMPHASIS">polled</i></span> method directs theoperating system to repeatedly ask the printer if it is ready for more data. When itresponds ready, the kernel sends more data.</p></li></ul><p>The interrupt-driven method is usually somewhat faster but uses up a precious IRQline. Some newer HP printers are claimed not to work correctly in interrupt mode,apparently due to some (not yet exactly understood) timing problem. These printers needpolled mode. You should use whichever one works. Some printers will work in both modes,but are painfully slow in interrupt mode.</p><p>You can set the communications mode in two ways: by configuring the kernel or by usingthe <span class="CITEREFENTRY"><span class="REFENTRYTITLE">lptcontrol</span>(8)</span>program.</p><p><span class="emphasis"><i class="EMPHASIS">To set the communications mode byconfiguring the kernel:</i></span></p><div class="PROCEDURE"><ol type="1"><li><p>Edit your kernel configuration file. Look for an <var class="LITERAL">ppc0</var>entry. If you are setting up the second parallel port, use <varclass="LITERAL">ppc1</var> instead. Use <var class="LITERAL">ppc2</var> for the thirdport, and so on.</p><ul><li><p>If you want interrupt-driven mode, for FreeBSD&nbsp;4.X add the <varclass="LITERAL">irq</var> specifier:</p><pre class="PROGRAMLISTING">device ppc0 at isa? irq <var class="REPLACEABLE">N</var></pre><p>Where <var class="REPLACEABLE">N</var> is the IRQ number for your computer's parallelport.</p><p>For FreeBSD&nbsp;5.X, edit the following line:</p><pre class="PROGRAMLISTING">hint.ppc.0.irq="<var class="REPLACEABLE">N</var>"</pre><p>in the <tt class="FILENAME">/boot/device.hints</tt> file and replace <varclass="REPLACEABLE">N</var> with the right IRQ number. The kernel configuration file mustalso contain the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">ppc</span>(4)</span> driver:</p><pre class="SCREEN">device ppc</pre></li><li><p>If you want polled mode, do not add the <var class="LITERAL">irq</var> specifier:</p><p>For FreeBSD&nbsp;4.X, use the following line in your kernel configuration file:</p><pre class="PROGRAMLISTING">device ppc0 at isa?</pre><p>For FreeBSD&nbsp;5.X, simply remove in your <ttclass="FILENAME">/boot/device.hints</tt> file, the following line:</p><pre class="PROGRAMLISTING">hint.ppc.0.irq="<var class="REPLACEABLE">N</var>"</pre><p>In some cases, this is not enough to put the port in polled mode underFreeBSD&nbsp;5.X. Most of time it comes from <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">acpi</span>(4)</span> driver, this latter is able to probe andattach devices, and therefore, control the access mode to the printer port. You shouldcheck your <span class="CITEREFENTRY"><span class="REFENTRYTITLE">acpi</span>(4)</span>configuration to correct this problem.</p></li></ul></li><li><p>Save the file. Then configure, build, and install the kernel, then reboot. See <ahref="kernelconfig.html">kernel configuration</a> for more details.</p></li></ol></div><p><span class="emphasis"><i class="EMPHASIS">To set the communications modewith</i></span> <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lptcontrol</span>(8)</span>:</p><div class="PROCEDURE"><ol type="1"><li><p>Type:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">lptcontrol -i -d /dev/lpt<varclass="REPLACEABLE">N</var></kbd></pre><p>to set interrupt-driven mode for <var class="LITERAL">lpt<varclass="REPLACEABLE">N</var></var>.</p></li><li><p>Type:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">lptcontrol -p -d /dev/lpt<varclass="REPLACEABLE">N</var></kbd></pre><p>to set polled-mode for <var class="LITERAL">lpt<varclass="REPLACEABLE">N</var></var>.</p></li></ol></div><p>You could put these commands in your <tt class="FILENAME">/etc/rc.local</tt> file toset the mode each time your system boots. See <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lptcontrol</span>(8)</span> for more information.</p></div><div class="SECT4"><h4 class="SECT4"><a id="PRINTING-TESTING" name="PRINTING-TESTING">9.3.1.3.2. CheckingPrinter Communications</a></h4><p>Before proceeding to configure the spooling system, you should make sure the operatingsystem can successfully send data to your printer. It is a lot easier to debug printercommunication and the spooling system separately.</p><p>To test the printer, we will send some text to it. For printers that can immediatelyprint characters sent to them, the program <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lptest</span>(1)</span> is perfect: it generates all 96 printableASCII characters in 96 lines.</p><p>For a <span class="TRADEMARK">PostScript</span> (or other language-based) printer, wewill need a more sophisticated test. A small <span class="TRADEMARK">PostScript</span>program, such as the following, will suffice:</p><pre class="PROGRAMLISTING">%!PS100 100 moveto 300 300 lineto stroke310 310 moveto /Helvetica findfont 12 scalefont setfont(Is this thing working?) showshowpage</pre><p>The above <span class="TRADEMARK">PostScript</span> code can be placed into a file andused as shown in the examples appearing in the following sections.</p><div class="NOTE"><blockquote class="NOTE"><p><b>注:</b> When this document refers to a printer language, it is assuming a languagelike <span class="TRADEMARK">PostScript</span>, and not Hewlett Packard's PCL. AlthoughPCL has great functionality, you can intermingle plain text with its escape sequences.<span class="TRADEMARK">PostScript</span> cannot directly print plain text, and that isthe kind of printer language for which we must make special accommodations.</p></blockquote></div><div class="SECT5"><h5 class="SECT5"><a id="PRINTING-CHECKING-PARALLEL"name="PRINTING-CHECKING-PARALLEL">9.3.1.3.2.1. Checking a Parallel Printer</a></h5><p>This section tells you how to check if FreeBSD can communicate with a printerconnected to a parallel port.</p><p><span class="emphasis"><i class="EMPHASIS">To test a printer on a parallelport:</i></span></p><div class="PROCEDURE"><ol type="1"><li><p>Become <tt class="USERNAME">root</tt> with <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">su</span>(1)</span>.</p></li><li><p>Send data to the printer.</p><ul><li><p>If the printer can print plain text, then use <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lptest</span>(1)</span>. Type:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">lptest &gt; /dev/lpt<varclass="REPLACEABLE">N</var></kbd></pre><p>Where <var class="REPLACEABLE">N</var> is the number of the parallel port, startingfrom zero.</p></li><li><p>If the printer understands <span class="TRADEMARK">PostScript</span> or other printerlanguage, then send a small program to the printer. Type:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cat &gt; /dev/lpt<varclass="REPLACEABLE">N</var></kbd></pre><p>Then, line by line, type the program <span class="emphasis"><iclass="EMPHASIS">carefully</i></span> as you cannot edit a line once you have pressed<var class="LITERAL">RETURN</var> or <var class="LITERAL">ENTER</var>. When you havefinished entering the program, press <var class="LITERAL">CONTROL+D</var>, or whateveryour end of file key is.</p><p>Alternatively, you can put the program in a file and type:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cat <varclass="REPLACEABLE">file</var> &gt; /dev/lpt<var class="REPLACEABLE">N</var></kbd></pre><p>Where <var class="REPLACEABLE">file</var> is the name of the file containing theprogram you want to send to the printer.</p></li></ul></li></ol></div><p>You should see something print. Do not worry if the text does not look right; we willfix such things later.</p></div><div class="SECT5"><h5 class="SECT5"><a id="PRINTING-CHECKING-SERIAL"name="PRINTING-CHECKING-SERIAL">9.3.1.3.2.2. Checking a Serial Printer</a></h5>

⌨️ 快捷键说明

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