← 返回命令列表

Linux command

setserial 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Example

setserial -a [/dev/ttyS0]

Example

setserial -b [/dev/ttyS0]

Set

sudo setserial [/dev/ttyS0] [parameter] [value]

Example

setserial -g [/dev/ttyS0] [/dev/ttyS1]

Auto-configure

sudo setserial [/dev/ttyS0] autoconfig

Example

sudo setserial [/dev/ttyS0] baud_base [115200] divisor [1]

说明

setserial configures and queries serial port settings including I/O port addresses, IRQ lines, UART types, and operational flags. It is primarily used during system startup to initialize serial ports beyond the standard COM1-COM4 ports or to configure non-standard hardware. The command can auto-detect UART types and set custom baud rates for specialized hardware. Modern systems with udev often handle serial configuration automatically, but setserial remains useful for legacy hardware and custom configurations.

参数

-a
Display all available configuration information
-b
Print summary configuration suitable for bootup scripts
-g
Report characteristics of multiple devices
-G
Print configuration as setserial command-line arguments
-q
Quiet mode; suppress status output
-v
Verbose mode; display additional status info
-V
Print version and exit
-z
Zero out flags before setting new values
port _port_number_
Set the I/O port address
irq _irq_number_
Set the interrupt request line
uart _uart_type_
Set UART type (none, 8250, 16450, 16550, 16550A, 16650, 16650V2, 16654, 16750, 16850, 16950, 16954)
autoconfig
Automatically detect UART type and IRQ
baud_base _baud_
Set base baud rate (clock frequency / 16)
divisor _divisor_
Set custom clock divisor for non-standard baud rates
spd_hi
Use 57600 baud when an application requests 38400 baud
spd_vhi
Use 115200 baud when an application requests 38400 baud
spd_cust
Use custom divisor (set via divisor parameter) when an application requests 38400 baud
spd_normal
Use standard 38400 baud rate (resets spd_hi, spd_vhi, etc.)
close_delay _delay_
Time in hundredths of a second that DTR should be kept low after port close
closing_wait _delay_
Time in hundredths of a second to wait for data to drain on close
auto_irq
Attempt to determine IRQ during autoconfig
^auto_irq
Disable automatic IRQ detection during autoconfig
skip_test
Skip UART test during autoconfig
low_latency
Minimize receive latency at the cost of CPU overhead

FAQ

What is the setserial command used for?

setserial configures and queries serial port settings including I/O port addresses, IRQ lines, UART types, and operational flags. It is primarily used during system startup to initialize serial ports beyond the standard COM1-COM4 ports or to configure non-standard hardware. The command can auto-detect UART types and set custom baud rates for specialized hardware. Modern systems with udev often handle serial configuration automatically, but setserial remains useful for legacy hardware and custom configurations.

How do I run a basic setserial example?

Run `setserial -a [/dev/ttyS0]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a do in setserial?

Display all available configuration information