PC上的串口一般是ttyS,板子上Linux的串口一般叫做ttySAC,是usb口转串口的是ttyUSB,外插串口卡的话默认是dev下的ttyS* ,一般ttyS0对应com1,ttyS1对应com2。
名词解释:TTY是TeleTYpe的一个老缩写。Teletypes,或者teletypewriters,原来指的是电传打字机,是通过串行线用打印机键盘通过阅读和发送信息的东西,和古老的电报机区别并不是很大。之后,当计算机只能以批处理方式运行时(当时穿孔卡片阅读器是唯一一种使程序载入运行的方式),电传打字机成为唯一能够被使用的“实时”输入/输出设备。最终,电传打字机被键盘和显示器终端所取代,但在终端或TTY接插的地方,操作系统仍然需要一个程序来监视串行端口。一个getty“Get TTY”的处理过程是:一个程序监视物理的TTY/终端接口。
串行接口简称串口,也称串行通信接口或串行通讯接口(通常指COM-cluster communication port),是采用串行通信方式的扩展接口。串行接口(Serial Interface) 是指数据一位一位地顺序传送,其特点是通信线路简单,只要一对传输线就可以实现双向通信(可以直接利用电话线作为传输线),从而大大降低了成本,特别适用于远距离通信,但传送速度较慢。
mac是一款类unix系统,然后源码如下:
#
# @(#)ttys 5.2 (Berkeley) 6/10/93
#
# name getty type status comments
#
#console "/usr/libexec/getty std.57600" vt100 on secure
console "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow" vt100 on secure onoption="/usr/libexec/getty std.9600"
#tahoe's only
#remote "/usr/libexec/getty std.1200" pt on # diagnostics
# The tty.serial entry initializes the serial port (if any) for use as a
# terminal (enabling logons over serial). If marked secure, the serial
# port will allow root logons.
# To make the serial port available for outbound
# communications, the tty.serial entry should be turned off
# (set the 4th field to off).
tty.serial "/usr/libexec/getty serial.57600" vt100 off secure
# Fax reception is off by default, use the
# System Preferences panel to enable it.
fax "/usr/bin/fax answer" unknown off
# Hardwired lines are marked off, by default, so getty(8)
# is quiet when they don't exist.
tty[00-07] "/usr/libexec/getty std.9600" unknown off secure
# pseudo-ttys
ttyp[0x0-0xf] none network slot=36
ttyq[0x0-0xf] none network
ttyr[0x0-0xf] none network
ttys[0x0-0xf] none network
ttyt[0x0-0xf] none network
ttyu[0x0-0xf] none network
ttyv[0x0-0xf] none network
ttyw[0x0-0xf] none network
# cloning ptys
ttys[000-999] none network
如果想要看自己当前占用的端口,在不同的终端窗口下输入tty命令即可以查看:
窗口1:
jiaozhiyudeMacBook-Pro:gif jiaozhiyu$ tty
/dev/ttys000
窗口2:
jiaozhiyudeMacBook-Pro:gif jiaozhiyu$ tty
/dev/ttys002
网友评论