像系统中的所有设备一样,串行端口通过设备特殊文件访问,这些文件位于 /dev 目录中。 有两种与串行驱动程序相关的设备文件类型,每个端口都有来自每种类型的一个设备文件。 根据访问的文件类型,设备的行为会有所不同。
第一种类型用于端口用于拨入时; 它的主设备号为 -4,文件名为 ttyS0、ttyS1 等。 第二种类型用于通过端口拨出时; 文件名为 cua0 等,主设备号为 -5。
次设备号对于两种类型是相同的。 如果您的调制解调器位于 COM1 到 COM4 端口之一,则其次设备号将是 COM 端口号加 63。 如果您的设置与此不同,例如当使用支持多条串行线的板卡时,请参阅串行 HOWTO。
假设您的调制解调器位于 COM2 上。 因此,其次设备号将为 -65,拨出时的主设备号将为 5。 应该有一个设备 cua1 具有这些号码。 列出 /dev 目录中的串行 ttys。 第 5 列和第 6 列应分别显示主设备号和次设备号
$ ls -l /dev/cua* crw-rw-rw- 1 root root 5, 64 Nov 30 19:31 /dev/cua0 crw-rw-rw- 1 root root 5, 65 Nov 30 22:08 /dev/cua1 crw-rw-rw- 1 root root 5, 66 Oct 28 11:56 /dev/cua2 crw-rw-rw- 1 root root 5, 67 Mar 19 1992 /dev/cua3如果没有这样的设备,您将需要创建一个: 成为超级用户并输入
# mknod -m 666 /dev/cua1 c 5 65 # chown root.root /dev/cua1 < /pre> Some people suggest making /dev/modem a symbolic link to your modem device, so that casual users don't have to remember the somewhat un-intuitive cua1. However, you cannot use modem in one program, and the real device file name in another. This is because these programs use so-called lock files to signal that the device is used. By convention, the lock file name for cua1, for instance, is LCK..cua1. Using different device files for the same port means that programs will fail to recognize each other's lock files, and will both use the device at the same time. As a result, both applications will not work at all.
![]()
Next: Serial Hardware Up: Setting up the Serial Previous: Introduction to Serial Devices Andrew Anderson
Thu Mar 7 23:22:06 EST 1996