#Bash 的 ldattach 命令
ldattach [OPTION]... LDISC DEVICE
功能
给终端设备(通常是串口)附加一个“线路规程(line discipline)”。
类型
可执行文件(/usr/sbin/ldattach),属于 util-linux。
参数
OPTION选项:-1,--onestopbit- 将串口的停止位数设置为 1-2,--twostopbits- 将串口的停止位数设置为 2-7,--sevenbits- 将串口的字符大小设置为 7 位-8,--eightbits- 将串口的字符大小设置为 8 位-d,--debug- 保持在前台运行,以便可以中断或调试-e,--evenparity- 将串口的校验设置为偶校验-i,--iflag value...- 设置串口c_iflag字中的指定位;可以是数字或名称,以减号(-)开头则清除指定的位-n,--noparity- 将串口的校验设置为无-o,--oddparity- 将串口的校验设置为奇校验-s,--speed value- 设置串口的速率(波特率)-c,--intro-command string- 定义一个在调用ldattach之前通过串口发送的引导命令-p,--pause value- 在调用ldattach之前休眠指定秒数;默认为 1-h,--help- 显示帮助-V,--version- 显示版本
LDISC- 线路规程DEVICE- 要操作的设备
#线路规程
| 名称 (标识) | 说明 (Description) |
|---|---|
| TTY(0) | 默认线路规程,提供透明操作(raw 模式)以及习惯的终端线路编辑功能(cooked 模式)。 |
| SLIP(1) | 串行线路 IP (SLIP) 协议处理器,用于通过串行线路传输 TCP/IP 数据包。 |
| MOUSE(2) | 用于连接 RS232 的指点设备(串行鼠标)的设备驱动程序。 |
| PPP(3) | 点对点协议 (PPP) 处理器,用于通过串行线路传输网络数据包。 |
| STRIP(4); AX25(5); X25(6) | 线路驱动程序,用于通过异步串行线路传输 X.25 数据包。 |
| 6PACK(7); R3964(9) | Simatic R3964 模块的驱动程序。 |
| IRDA(11) | Linux IrDa(红外数据传输)驱动程序 - 参见 http://irda.sourceforge.net/ |
| HDLC(13) | 同步 HDLC 驱动程序。 |
| SYNC_PPP(14) | 同步 PPP 驱动程序。 |
| HCI(15) | 蓝牙 HCI UART 驱动程序。 |
| GIGASET_M101(16) | 西门子 Gigaset M101 串行 DECT 适配器的驱动程序。 |
| PPS(18) | 串行线路每秒脉冲 (PPS) 源的驱动程序。 |
| GSM0710(21) | GSM 07.10 多路复用协议调制解调器 (CMUX) 的驱动程序。 |
#示例
GPS(NMEA)
$ ldattach nmea /dev/ttyS0
蓝牙 HCI(UART)
$ ldattach hci /dev/ttyS1
拨号网络 PPP
$ ldattach ppp /dev/ttyS0
调制解调器 GSM
$ ldattach gsm /dev/ttyUSB0
#推荐阅读
#手册
LDATTACH(8) System Administration LDATTACH(8)
NAME
ldattach - attach a line discipline to a serial line
SYNOPSIS
ldattach [-1278denoVh] [-i iflag] [-s speed] ldisc device
DESCRIPTION
The ldattach daemon opens the specified device file (which should refer
to a serial device) and attaches the line discipline ldisc to it for
processing of the sent and/or received data. It then goes into the
background keeping the device open so that the line discipline stays
loaded.
The line discipline ldisc may be specified either by name or by number.
In order to detach the line discipline, kill(1) the ldattach process.
With no arguments, ldattach prints usage information.
LINE DISCIPLINES
Depending on the kernel release, the following line disciplines are
supported:
TTY(0)
The default line discipline, providing transparent operation (raw
mode) as well as the habitual terminal line editing capabilities
(cooked mode).
SLIP(1)
Serial Line IP (SLIP) protocol processor for transmitting TCP/IP
packets over serial lines.
MOUSE(2)
Device driver for RS232 connected pointing devices (serial mice).
PPP(3)
Point to Point Protocol (PPP) processor for transmitting network
packets over serial lines.
STRIP(4); AX25(5); X25(6)
Line driver for transmitting X.25 packets over asynchronous serial
lines.
6PACK(7); R3964(9)
Driver for Simatic R3964 module.
IRDA(11)
Linux IrDa (infrared data transmission) driver - see
http://irda.sourceforge.net/
HDLC(13)
Synchronous HDLC driver.
SYNC_PPP(14)
Synchronous PPP driver.
HCI(15)
Bluetooth HCI UART driver.
GIGASET_M101(16)
Driver for Siemens Gigaset M101 serial DECT adapter.
PPS(18)
Driver for serial line Pulse Per Second (PPS) source.
GSM0710(21)
Driver for GSM 07.10 multiplexing protocol modem (CMUX).
OPTIONS
-1, --onestopbit
Set the number of stop bits of the serial line to one.
-2, --twostopbits
Set the number of stop bits of the serial line to two.
-7, --sevenbits
Set the character size of the serial line to 7 bits.
-8, --eightbits
Set the character size of the serial line to 8 bits.
-d, --debug
Keep ldattach in the foreground so that it can be interrupted or
debugged, and to print verbose messages about its progress to
standard error output.
-e, --evenparity
Set the parity of the serial line to even.
-i, --iflag value...
Set the specified bits in the c_iflag word of the serial line. The
given value may be a number or a symbolic name. If value is
prefixed by a minus sign, the specified bits are cleared instead.
Several comma-separated values may be given in order to set and
clear multiple bits.
-n, --noparity
Set the parity of the serial line to none.
-o, --oddparity
Set the parity of the serial line to odd.
-s, --speed value
Set the speed (the baud rate) of the serial line to the specified
value.
-c, --intro-command string
Define an intro command that is sent through the serial line before
the invocation of ldattach. E.g. in conjunction with line
discipline GSM0710, the command 'AT+CMUX=0\r' is commonly suitable
to switch the modem into the CMUX mode.
-p, --pause value
Sleep for value seconds before the invocation of ldattach. Default
is one second.
-h, --help
Display help text and exit.
-V, --version
Print version and exit.
AUTHORS
Tilman Schmidt <[email protected]>
SEE ALSO
inputattach(1), ttys(4)
REPORTING BUGS
For bug reports, use the issue tracker at
https://github.com/util-linux/util-linux/issues.
AVAILABILITY
The ldattach command is part of the util-linux package which can be
downloaded from Linux Kernel Archive
<https://www.kernel.org/pub/linux/utils/util-linux/>.
util-linux 2.39.3 2023-10-23 LDATTACH(8)