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

📄 serial.html

📁 FreeBSD安装说明概述 FreeBSD 提供了一个以文字为主
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</li><li><p>Call-out ports are named <tt class="FILENAME">/dev/cuaa<varclass="REPLACEABLE">N</var></tt>. You usually do not use the call-out port for terminals,just for modems. You may use the call-out port if the serial cable or the terminal doesnot support the carrier detect signal.</p></li></ul><p>If you have connected a terminal to the first serial port (<ttclass="DEVICENAME">COM1</tt> in <span class="TRADEMARK">MS-DOS</span>&reg;), then youwill use <tt class="FILENAME">/dev/ttyd0</tt> to refer to the terminal. If the terminalis on the second serial port (also known as <tt class="DEVICENAME">COM2</tt>), use <ttclass="FILENAME">/dev/ttyd1</tt>, and so forth.</p></div></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN22039" name="AEN22039">17.2.3. Kernel Configuration</a></h2><p>FreeBSD supports four serial ports by default. In the <spanclass="TRADEMARK">MS-DOS</span> world, these are known as <ttclass="DEVICENAME">COM1</tt>, <tt class="DEVICENAME">COM2</tt>, <ttclass="DEVICENAME">COM3</tt>, and <tt class="DEVICENAME">COM4</tt>. FreeBSD currentlysupports ``dumb'' multiport serial interface cards, such as the BocaBoard 1008 and 2016,as well as more intelligent multi-port cards such as those made by Digiboard and StallionTechnologies. However, the default kernel only looks for the standard COM ports.</p><p>To see if your kernel recognizes any of your serial ports, watch for messages whilethe kernel is booting, or use the <tt class="COMMAND">/sbin/dmesg</tt> command to replaythe kernel's boot messages. In particular, look for messages that start with thecharacters <var class="LITERAL">sio</var>.</p><div class="TIP"><blockquote class="TIP"><p><b>Tip:</b> To view just the messages that have the word <varclass="LITERAL">sio</var>, use the command:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">/sbin/dmesg | grep 'sio'</kbd></pre></blockquote></div><p>For example, on a system with four serial ports, these are the serial-port specifickernel boot messages:</p><pre class="SCREEN">sio0 at 0x3f8-0x3ff irq 4 on isasio0: type 16550Asio1 at 0x2f8-0x2ff irq 3 on isasio1: type 16550Asio2 at 0x3e8-0x3ef irq 5 on isasio2: type 16550Asio3 at 0x2e8-0x2ef irq 9 on isasio3: type 16550A</pre><p>If your kernel does not recognize all of your serial ports, you will probably need toconfigure a custom FreeBSD kernel for your system. For detailed information onconfiguring your kernel, please see <a href="kernelconfig.html">Chapter 9</a>.</p><p>The relevant device lines for your kernel configuration file would look like this, forFreeBSD&nbsp;4.X:</p><pre class="PROGRAMLISTING">device     sio0    at isa? port IO_COM1 irq 4device      sio1    at isa? port IO_COM2 irq 3device      sio2    at isa? port IO_COM3 irq 5device      sio3    at isa? port IO_COM4 irq 9</pre><p>and like this, for FreeBSD&nbsp;5.X:</p><pre class="PROGRAMLISTING">device     sio</pre><p>You can comment-out or completely remove lines for devices you do not have in the caseof FreeBSD&nbsp;4.X; for FreeBSD&nbsp;5.X you have to edit your <ttclass="FILENAME">/boot/device.hints</tt> file to configure your serial ports. Pleaserefer to the <span class="CITEREFENTRY"><span class="REFENTRYTITLE">sio</span>(4)</span>manual page for more information on serial ports and multiport boards configuration. Becareful if you are using a configuration file that was previously used for a differentversion of FreeBSD because the device flags and the syntax have changed betweenversions.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> <var class="LITERAL">port IO_COM1</var> is a substitution for <varclass="LITERAL">port 0x3f8</var>, <var class="LITERAL">IO_COM2</var> is <varclass="LITERAL">0x2f8</var>, <var class="LITERAL">IO_COM3</var> is <varclass="LITERAL">0x3e8</var>, and <var class="LITERAL">IO_COM4</var> is <varclass="LITERAL">0x2e8</var>, which are fairly common port addresses for their respectiveserial ports; interrupts 4, 3, 5, and 9 are fairly common interrupt request lines. Alsonote that regular serial ports <span class="emphasis"><iclass="EMPHASIS">cannot</i></span> share interrupts on ISA-bus PCs (multiport boards haveon-board electronics that allow all the 16550A's on the board to share one or twointerrupt request lines).</p></blockquote></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN22081" name="AEN22081">17.2.4. Device Special Files</a></h2><p>Most devices in the kernel are accessed through ``device special files'', which arelocated in the <tt class="FILENAME">/dev</tt> directory. The <ttclass="DEVICENAME">sio</tt> devices are accessed through the <ttclass="FILENAME">/dev/ttyd<var class="REPLACEABLE">N</var></tt> (dial-in) and <ttclass="FILENAME">/dev/cuaa<var class="REPLACEABLE">N</var></tt> (call-out) devices.FreeBSD also provides initialization devices (<tt class="FILENAME">/dev/ttyid<varclass="REPLACEABLE">N</var></tt> and <tt class="FILENAME">/dev/cuaia<varclass="REPLACEABLE">N</var></tt>) and locking devices (<ttclass="FILENAME">/dev/ttyld<var class="REPLACEABLE">N</var></tt> and <ttclass="FILENAME">/dev/cuala<var class="REPLACEABLE">N</var></tt>). The initializationdevices are used to initialize communications port parameters each time a port is opened,such as <var class="LITERAL">crtscts</var> for modems which use <varclass="LITERAL">RTS/CTS</var> signaling for flow control. The locking devices are used tolock flags on ports to prevent users or programs changing certain parameters; see themanual pages <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">termios</span>(4)</span>, <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">sio</span>(4)</span>, and <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">stty</span>(1)</span> for information on the terminal settings,locking and initializing devices, and setting terminal options, respectively.</p><div class="SECT3"><h3 class="SECT3"><a id="AEN22110" name="AEN22110">17.2.4.1. Making Device SpecialFiles</a></h3><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> FreeBSD&nbsp;5.0 includes the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">devfs</span>(5)</span> filesystem which automatically createsdevice nodes as needed. If you are running a version of FreeBSD with <varclass="LITERAL">devfs</var> enabled then you can safely skip this section.</p></blockquote></div><p>A shell script called <tt class="COMMAND">MAKEDEV</tt> in the <ttclass="FILENAME">/dev</tt> directory manages the device special files. To use <ttclass="COMMAND">MAKEDEV</tt> to make dial-up device special files for <ttclass="DEVICENAME">COM1</tt> (port 0), <tt class="COMMAND">cd</tt> to <ttclass="FILENAME">/dev</tt> and issue the command <tt class="COMMAND">MAKEDEV ttyd0</tt>.Likewise, to make dial-up device special files for <tt class="DEVICENAME">COM2</tt> (port1), use <tt class="COMMAND">MAKEDEV ttyd1</tt>.</p><p><tt class="COMMAND">MAKEDEV</tt> not only creates the <ttclass="DEVICENAME">/dev/ttyd<var class="REPLACEABLE">N</var></tt> device special files,but also the <tt class="DEVICENAME">/dev/cuaa<var class="REPLACEABLE">N</var></tt>, <ttclass="DEVICENAME">/dev/cuaia<var class="REPLACEABLE">N</var></tt>, <ttclass="DEVICENAME">/dev/cuala<var class="REPLACEABLE">N</var></tt>, <ttclass="DEVICENAME">/dev/ttyld<var class="REPLACEABLE">N</var></tt>, and <ttclass="DEVICENAME">/dev/ttyid<var class="REPLACEABLE">N</var></tt> nodes.</p><p>After making new device special files, be sure to check the permissions on the files(especially the <tt class="FILENAME">/dev/cua*</tt> files) to make sure that only userswho should have access to those device special files can read and write on them -- youprobably do not want to allow your average user to use your modems to dial-out. Thedefault permissions on the <tt class="FILENAME">/dev/cua*</tt> files should besufficient:</p><pre class="SCREEN">crw-rw----    1 uucp     dialer    28, 129 Feb 15 14:38 /dev/cuaa1crw-rw----    1 uucp     dialer    28, 161 Feb 15 14:38 /dev/cuaia1crw-rw----    1 uucp     dialer    28, 193 Feb 15 14:38 /dev/cuala1</pre><p>These permissions allow the user <tt class="USERNAME">uucp</tt> and users in the group<tt class="USERNAME">dialer</tt> to use the call-out devices.</p></div></div><div class="SECT2"><h2 class="SECT2"><a id="SERIAL-HW-CONFIG" name="SERIAL-HW-CONFIG">17.2.5. Serial PortConfiguration</a></h2><p>The <tt class="DEVICENAME">ttyd<var class="REPLACEABLE">N</var></tt> (or <ttclass="DEVICENAME">cuaa<var class="REPLACEABLE">N</var></tt>) device is the regulardevice you will want to open for your applications. When a process opens the device, itwill have a default set of terminal I/O settings. You can see these settings with thecommand</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">stty -a -f /dev/ttyd1</kbd></pre><p>When you change the settings to this device, the settings are in effect until thedevice is closed. When it is reopened, it goes back to the default set. To make changesto the default set, you can open and adjust the settings of the ``initial state'' device.For example, to turn on <var class="OPTION">CLOCAL</var> mode, 8 bit communication, and<var class="OPTION">XON/XOFF</var> flow control by default for <ttclass="DEVICENAME">ttyd5</tt>, type:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">stty -f /dev/ttyid5 clocal cs8 ixon ixoff</kbd></pre><p>System-wide initialization of the serial devices is controlled in <ttclass="FILENAME">/etc/rc.serial</tt>. This file affects the default settings of serialdevices.</p><p>To prevent certain settings from being changed by an application, make adjustments tothe ``lock state'' device. For example, to lock the speed of <ttclass="DEVICENAME">ttyd5</tt> to 57600&nbsp;bps, type:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">stty -f /dev/ttyld5 57600</kbd></pre><p>Now, an application that opens <tt class="DEVICENAME">ttyd5</tt> and tries to changethe speed of the port will be stuck with 57600&nbsp;bps.</p><p>Naturally, you should make the initial state and lock state devices writable only bythe <tt class="USERNAME">root</tt> account.</p></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="serialcomms.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="term.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Serial Communications</td><td width="34%" align="center" valign="top"><a href="serialcomms.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Terminals</td></tr></table></div></body></html>

⌨️ 快捷键说明

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