Use the setserial command

Source: Internet
Author: User
Tags ranges

Note that this is not an internal command, but an independent hairstyle. You need to download the source code and compile it.

Serial port settings in Linux

Name

Setserial-Get/set the LINUX serial port information
Overview

Setserial [-Abqvvwz]Device[Command parameter 1[Device variable parameters]...Setserial-G [-Abgv]Device 1...
Description

SetserialIt is a program used to set and obtain information and settings related to a serial port. The information includes the I/O address and interrupt number used by a serial port, and whether the Break Key is used as a key that attracts security attention.

During normal boot, only the ports COM1 to com4 are initialized, and the default I/O address and interrupt number are used, as listed below. To initialize other serial ports, or change the settings from COM1 to com4 to a non-standard setting. Must be usedSetserialProgram. Generally, this program willRC. SerialUsed in the script./Etc/rc. Local.
Executed

Device
The serial device to be set as defined by the variable element parameter. They generally take the following forms:/Dev/CUA [0-3].

If no command parameter is set,Setserial
The port type (for example, 8250,16450, 14330,165 50a, etc.) will be printed ),
Hardware I/O addresses, also disconnected numbers, port numbers, and some operable or changed identifiers in each hardware.

If you select-GThe command will list some basic information about the given device parameters.

If no parameter is specified, the first device variable is used as the target device to modify or display the content. Other device variable parameters are assigned to the target device as command parameters.

In most cases, you must have the system administrator privilege to set the serial port. Of course, there are some serial port parameters that can be set by common users. These parameters will be described in this manual.

Option

SetserialThe following parameters are acceptable:

-
All valid information is displayed when the configuration of the serial port device is output.
-B
When the configuration of a serial port device is output, the main device settings are output. This option is suitable for outputting device information in the/etc/rc script during the boot process.
-G
Output the configuration information of the serial port in a specific form. In this form, you can set the information to return to the serial port device in the form of command line parameters.
-Q
Silent.
Setserial
The command will be output in a more concise form.
-V
Output details. SetserialOutput additional status information.
-V
Display version information and exit.
-W
Force initialization, disconnect, and exit. Some options are not provided in Linux after core version 2.1. -ZClear the serial mark of the original settings before starting to set the flag. This item is related to the setting mark that uses the-G flag to automatically save the serial port.


Command Parameters

The following command parameters can be assigned to a serial port.

All parameter values are assumed to be an octal number, unless the value is marked with "0x ".

PortPort Number
PortThis option sets the I/O address as above.
IRQInterrupt number
IRQThis option sets the hardware interrupt number IRQ as above.
UARTAsynchronous Communication (UART) Type
This option is used to set the asynchronous communication (UART) type. The allowed types are: None, 8250,16450, 16550,165 50a, 16550,166 50v2, and 16750. in addition, the 8250 type and 16450 do not have FIFO's. Some errors in the first 16550 make the FIFO's unavailable, and the FIFO can only be used for asynchronous communication machines of the 16550a type. Set the asynchronous communication (UART) type to 8250,16450, or 16550 to enable the serial port that does not use FIFO. Use the asynchronous communication type NonePort is disabled.

Some inner cats mark "16.0a UART with 1 K buffer", which is a lie. they do not have uarts that are truly compatible with 16550a; instead, they only have a 16450 compatible UART with a 1 K receive buffer to prevent overflow during receiving. this is very important, because they do not have one that can transmit FIFO. therefore, they are not compatible with 16.0a UART, and the automatic configuration process correctly recognizes them as 16450 type. If you want to use it forcibly, you mustUARTParameters, so that you will find a loss of characters when transferring files. These uarts usually have other problems.Skip TestParameters are also frequently used.AutoConfigWhen this parameter is used,SetserialThe serial port. I/O address will be automatically set in the request to the core. The core will try to detect the UART type. IfAuto_irqParameter Selection. Linux will try to automatically allocate the interrupt number IRQ.AutoConfigParameters should be inPort, auto_irq, And skip_test and other parameters are also specified after use.

Auto_irq
During the automatic configuration process, the interrupt number IRQ will be automatically assigned. This function cannot guarantee a correct result. Some hardware configurations may confuse the Linux core. Generally, no parameters are used. Auto_irq
The IRQ interrupt number is more secure. IRQ
The parameter specifies the interrupt number.
^ Auto_irq
And NoTrying to allocate the interrupt number IRQ.
Skip_test
During automatic configuration, UART detection is ignored. some inner cats do not have the UART device type compatible with international semiconductor companies, and there are only some cheap counterfeits. some do not even fully support the loopback detection mode. This mode is used by the core to determine whether there is a UART device on a specific address before trying to configure it. therefore, for some inner cats, you may need to specify this parameter so that Linux can correctly initialize UART.
^ Skip_tet
During automatic configuration, NoIgnore UART detection.
Baud_basePorter base rate
This option sets the port baud rate. This value is the clock frequency divided by 16. Generally, this value is 115200, which is also the fastest baud rate supported by UART.
Spd_hi
When the program requires 38.4kb, the connection speed of 57.6kb is used. This parameter can be specified by unprivileged users.
Spd_vhi
The connection speed of 115kb is used when 38.4kb is required. Spd_custWhen the request is 38.4kb, the specified divisor (divisor) is used to calculate the speed. Baud_base (Porter base rate)
Divided Divisor (divisor)Get
Spd_normal
The speed of 38.4kb is used when 38.4kb is required. This parameter can be specified by a non-privileged user.
DivisorDivisor (divisor)
This option specifies the customized divisor. This divisor will be used in Spd_custWhen the speed of 38.4kb is required, the parameter is used to set the connection speed of the serial port. This parameter can be set by a non-privileged common user.
SAK
Set the Break Key to the key that triggers Security attention.
^ Sak
Disable the Security note key.
Fourport
Configure the port to an ast fouroart card.
^ Fourport
Disable ast fourport configuration.
CloseDelay Delay)
The specified time length, in the unit of 1% seconds. After the DTr device is disconnected, it will still maintain a low-speed serial path and restart DTR before data comes in. the default value of this option is 50, that is, the half-second delay.
Close_delayDelay)
Specifies the length of time. The unit is 1% seconds. When the port is closed before the receiver is disabled, the core needs to wait for data from the serial port. if it is specified as "NONE", there will be no delay. if "infinite" is specified, the core will wait for the transmission of buffered data for Uncertain Time. the default value of this option is "NONE ".
Closing_wait2Delay)
The length of the specified time. The unit is 1% seconds. When the receiver is disabled, the core waits for data from the serial port when the port is closed. Closing_waitThe "NONE" and "infinite" parameters are both specified. The default value of this parameter is 3000, that is, the delay of 30 seconds. The default values of closing_wait and closing_wait2 apply to most devices. If the selected delay is too long, when the serial port is disconnected, it will be suspended for too long, resulting in data suspension and elimination. If it is set too short, it may cause some transmitted data to overflow.

If the device is very slow, like a plotter, the two values may increase.

If the device uses the Xon/xoff signal exchange, the default value is reversed. However, this may cause a "Echo conflict" between Linux and echo cat ".

Session_lockout
For different tasks, lock the port of the connected device (/dev/cuaxx). That is to say, once a process opens the port, other tasks with different numbers are not allowed to open the port, until the previous process releases this port.
^ Session_lockout
The uplink port does not enable the above function.
Pgrp_lockout
Lock the connected port (/dev/cuaxx) for different process groups ). That is to say, once a process opens a port, other process groups are not allowed to share the port until the previous process releases it.

One application of this parameter is when a login end is locked by a dial-up serial port. It will allow the login end to reset the modem (using the program of the specified device may modify its settings) before the lock is enabled.

^ Hup_policy
When the process is locked for a dial-up, and the mail device is suspended, the process is not notified.
Split_termios
The terminal settings for connecting devices are treated separately from those for connecting devices.
^ Split) termios
This parameter is the default option.
Callout_nohup
If this special serial port is opened as an out-of-band device, the communication port is not suspended when the carrier detection disappears.
^ Callout_nohup
When a serial port is opened as an out-of-connection device, the communication port is not suspended. Of course, if it is suspended, the hupcl terminal identity will be enabled.
^ Low_latency
A higher CPU usage is used to minimize latency. (Delay of 5-10 ms in transmission is usually used to minimize system overhead.) This default value is disabled, but this parameter may be used by some real-time programs.


Conisiderations of login ing serial ports

Understanding the setserial command is just to tell the Linux core that it is very important to find the interrupt numbers IRQ of the I/O address of a specific port. It does not operate on hardware. A specific I/O address is actually used by the serial device. To change the actual hardware parameters, You need to manually set the hardware, usually the jumper, or change the dip switch.

The following section provides some help for setting your serial port.

The following are the port settings for "Standard MS-dos:

 
/Dev/ttys0 (COM1), Port 0x3f8, IRQ 4
/Dev/ttys1 (com2), Port 0x2f8, IRQ 3
/Dev/ttys2 (com3), Port 0x3e8, IRQ 4
/Dev/ttys3 (com4), Port 0x2e8, IRQ 3

Generally, the interrupt number IRQ cannot be shared by more than two serial ports according to the AT/ISA bus structure. If you try to do this, one or all of the two ports will be unreliable when both ports are enabled. This restriction can be overcome by a multi-port serial port board, which is used to allow multiple serial ports to share an interrupt number IRQ. Support for Linux has been added to Ast fourport, accent async board, Usenet serial II board, bocabord BB-1004, BB-1008, and BB-2016 board, and hub-6 serial board.

It is difficult to modify the interrupt number IRQ for a device, because most of the interrupt numbers have been used, the following is a list of valid interrupt numbers set by the standard MS-DOS:

 
IRQ 3: com2
IRQ 4: COM1
IRQ 5: lpt2
IRQ 7: LPT1

Many people have found that the interrupt number IRQ 5 is a good choice, assuming that only one parallel port in the computer is in use. The interrupt number IRQ 2 is also a good choice (or may be 9). Although the interrupt number IRQ is sometimes used by the NIC, there are also a few graphics cards that may use the interrupt number IRQ 2 as an interrupt for vertical scanning. If your video card is set in this way, you may need to disable this function to release an interruption to other devices. Of course, this is not necessarily required for Linux or other operating systems.

In addition, other available interrupt numbers include 3, 4, and 7, which may also be used by other serial or parallel ports. (If your serial card has a 16-bit wiring port for the electronic data collector and supports a higher interrupt number, then the interrupt number IRQ 10, 11, 12, and 15 are also available .)

In some at machines, the interrupt number IRQ 2 is treated as the interrupt number IRQ 9, so Linux will think so.

Other interrupt numbers except 2 (9), 3, 4, 5, 7, 10, 11, 12, and 15NoThey can be used because they are assigned to other hardware and cannot be changed. The following are some "standard" Settings:

 
IRQ 0 clock generator 0
IRQ 1 keyboard
IRQ 2 Programmable Interrupt Controller 2
IRQ 3 Serial Port 2
IRQ 4 Serial Port 1
IRQ 5 Parallel Port 2 (reserved to PS/2)
IRQ 6 floppy disk drive
IRQ 7 Parallel Port 1
IRQ 8 System Real-Time Clock
IRQ 9 redirects to the interrupt number IRQ 2
IRQ 10 reserved
IRQ 11 Reserved
IRQ 12 reserved (PS/2 compatible devices)
IRQ 13 math coprocessor
IRQ 14 Hard Drive Controller
IRQ 15 Reserved

Multiport Configuration

Some multi-port serial boards allow multiple terminals to share an interrupt number and use one or more ports to show whether a port needs to be served. If your multi-port lvban supports these ports, you must ensure that the potential deadlock can be avoided if the interruption is lost.

To set these ports in detail, useSet_multiportIs a parameter followed by a multi-port parameter. Parameters in this multi-terminal must be specified in the following format:PortYou need to check the parameters.MaskIt can be shown in the registered bits that is important, and the final ParameterMathUsed to specify the registered bits. When no further work is required, the bits must match.

When there are four such types of/port/mask/match, you must specify the union. The first such combination should use the following parameters:Port1, Mask1,AndMatebook. The second combination must be specified using the following parameters:Port2, Mask2,AndMatch2,And so on. To disable this multi-port detection, SetPort1Zero.

If you want to view the current multi-port settings, specify the command line parametersGet_multiport

The following are some general settings of the serial board:

 
Ast fourport port1 0x1bf match1 0xf mask1 0xf

Boca BB-1004/8 port1 0x107 mate8 0xff mate8 0

Boca BB-2016 port1 0x107 mate8 0xff mate8 0
Port2 0x147 match2 0xff match2 0

Hayes ESP settings

SetserialIt can also be used to set a port on the ESP serial board of the heshi.

The following parameters are used in settings:

Rx_trigger
This is the trigger level of A received FIFO (in bytes). A large value can reduce the interruption time and improve performance. However, a large value may cause data loss. Valid values range from 1 to 1023.
Tx_trigger
This is the trigger level of a first-in-second. Valid values range from 1 to 1023.
Flow_off
This indicates that the ESP port is disconnected from the remote transmission (for example, telling it to stop sending data). The valid value ranges from 1 to 1023, which is higher than the received trigger level and connection level value.
Flow_on
This is the level (in bytes) of the ESP port notification connection. (for example, after a notification is sent again, the valid value ranges from 1 to 1023. this value should be lower than the flow off level value but higher than the received trigger level.
Rx_timeout
This is the time that the ESP port will wait before it receives the last character and before the interruption signal. Valid values are from 0 to 255. The value is too large to increase the latency, and too small will cause unnecessary interruption.

Warning

Warning using an incorrect I/O address when setting a serial port may cause a crash.

File

/Etc/rc. Local /Etc/rc. Serial

See also,

Tty (4 ), TTYs (4 ),Kernel/chr_drv/serial. c

Author

The first version of seterial was made by Rick sladkey (jrs@world.std.com), followed by Michael K. Johnson (johsonm@stolaf.edu ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.