Carambola2 unlike Carambola1 features on-board USB to Serial FTDI interface. Run program, enter COM port number, select baudrate 115200 and click 'connect'. Get latest sources from 8devices OpenWrt branch.
Name
setserial - get/set Linux serial port informationSynopsis
setserial [ -abqvVWz ] device [ parameter1 [ arg ] ] ...setserial -g [ -abGv ] device1 ...
Description
setserial is a program designed to set and/or report the configuration informationassociated with a serial port. This information includes what I/O port and IRQ a particular serial port is using, and whether or not the break key should beinterpreted as the Secure Attention Key, and so on.During the normal bootup process, only COM ports 1-4 are initialized, using the default I/O ports and IRQ values, as listed below. In order to initializeany additional serial ports, or to change the COM 1-4 ports to a nonstadard configuration, the setserial program should be used. Typically it is calledfrom an rc.serial script, which is usually run out of /etc/rc.local.
The device argument or arguments specifies the serial device which should be configured or interrogated. It will usually have the following form:/dev/cua[0-3].
If no parameters are specified, setserial will print out the port type (i.e., 8250, 16450, 16550, 16550A, etc.), the hardware I/O port, the hardwareIRQ line, its 'baud base,' and some of its operational flags.
If the -g option is given, the arguments to setserial are interpreted as a list of devices for which the characteristics of those devices should beprinted.
Without the -g option, the first argument to setserial is interpreted as the device to be modified or characteristics to be printed, and anyadditional arguments are interpreted as parameters which should be assigned to that serial device.
For the most part, superuser privilege is required to set the configuration parameters of a serial port. A few serial port parameters can be set by normalusers, however, and these will be noted as exceptions in this manual page.
Options
Setserial accepts the following options:- -G
- Print out the configuration information of the serial port in a form which can be fed back to setserial as command-line arguments.
- -q
- Be quiet. Setserial will print fewer lines of output.
- -v
- Be verbose. Setserial will print additional status output.
- -V
- Display version and exit.
- -W
- Do wild interrupt initialization and exit. This option is no longer relevant in Linux kernels after version 2.1.
- -z
- Zero out the serial flags before starting to set flags. This is related to the automatic saving of serial flags using the -G flag.
Parameters
The following parameters can be assigned to a serial port.All argument values are assumed to be in decimal unless preceeded by '0x'.
Some internal modems are billed as having a '16550A UART with a 1k buffer'. This is a lie. They do not have really have a 16550A compatible UART; insteadwhat they have is a 16450 compatible UART with a 1k receive buffer to prevent receiver overruns. This is important, because they do not have a transmit FIFO.Hence, they are not compatible with a 16550A UART, and the autoconfiguration process will correctly identify them as 16450's. If you attempt to override thisusing the uart parameter, you will see dropped characters during file transmissions. These UART's usually have other problems: the skip_testparameter also often must be specified.
![Openwrt Serial Port Programming Tutorial Openwrt Serial Port Programming Tutorial](https://img.alicdn.com/imgextra/i3/90388347/TB2gCPAdXXXXXbrXpXXXXXXXXXX_!!90388347.jpg)
The application of this parameter is for getty's which are blocked on a serial port's dial in line. This allows the getty to reset the modem (which may havehad its configuration modified by the application using the callout device) before blocking on the open again.
Considerations of Configuring Serial Ports
It is important to note that setserial merely tells the Linuxkernel where it should expect to find the I/O port and IRQ lines of a particular serial port. It does *not* configure the hardware, the actual serial board, touse a particular I/O port. In order to do that, you will need to physically program the serial board, usually by setting some jumpers or by switching some DIPswitches.This section will provide some pointers in helping you decide how you would like to configure your serial ports.
The 'standard MS-DOS' port associations are given below:Due to the limitations in the design of the AT/ISA bus architecture, normally an IRQ line may not be shared between two or more serial ports. If you attemptto do this, one or both serial ports will become unreliable if you try to use both simultaneously. This limitation can be overcome by special multi-port serialport boards, which are designed to share multiple serial ports over a single IRQ line. Multi-port serial cards supported by Linux include the AST FourPort, theAccent Async board, the Usenet Serial II board, the Bocaboard BB-1004, BB-1008, and BB-2016 boards, and the HUB-6 serial board.
The selection of an alternative IRQ line is difficult, since most of them are already used. The following table lists the 'standard MS-DOS' assignments ofavailable IRQ lines:Most people find that IRQ 5 is a good choice, assuming that there is only one parallel port active in the computer. Another good choice is IRQ 2 (aka IRQ9); although this IRQ is sometimes used by network cards, and very rarely VGA cards will be configured to use IRQ 2 as a vertical retrace interrupt. If yourVGA card is configured this way; try to disable it so you can reclaim that IRQ line for some other card. It's not necessary for Linux and most other Operatingsystems.
The only other available IRQ lines are 3, 4, and 7, and these are probably used by the other serial and parallel ports. (If your serial card has a 16bitcard edge connector, and supports higher interrupt numbers, then IRQ 10, 11, 12, and 15 are also available.)
On AT class machines, IRQ 2 is seen as IRQ 9, and Linux will interpret it in this manner.
IRQ's other than 2 (9), 3, 4, 5, 7, 10, 11, 12, and 15, should not be used, since they are assigned to other hardware and cannot, in general, bechanged. Here are the 'standard' assignments:
Multiport Configuration
Certain multiport serial boards which share multiple ports on a single IRQ use one or more ports to indicate whether or not there are any pending portswhich need to be serviced. If your multiport board supports these ports, you should make use of them to avoid potential lockups if the interrupt gets lost.
In order to set these ports specify set_multiport as a parameter, and follow it with the multiport parameters. The multiport parameters take the formof specifying the port that should be checked, a mask which indicate which bits in the register are significant, and finally, a matchparameter which specifies what the significant bits in that register must match when there is no more pending work to be done.
Up to four such port/mask/match combinations may be specified. The first such combinations should be specified by setting the parameters port1,mask1, and match1. The second such combination should be specified with port2, mask2, and match2, and so on. In order todisable this multiport checking, set port1 to be zero.
In order to view the current multiport settings, specify the parameter get_multiport on the command line.
Here are some multiport settings for some common serial boards:
Hayes ESP Configuration
Setserial may also be used to configure ports on a Hayes ESP serial board.The following parameters when configuring ESP ports:
- flow_on
- This is the level (in bytes) at which the ESP port will 'flow on' the remote transmitter (i.e. tell him to resume sending bytes) after having flowed itoff. Valid values are 1 through 1023. This value should be less than the flow off level, but greater than the receive trigger level.
- rx_timeout
- This is the amount of time that the ESP port will wait after receiving the final character before signaling an interrupt. Valid values are 0 through 255. Avalue too high will increase latency, and a value too low will cause unnecessary interrupts.
Caution
CAUTION: Configuring a serial port to use an incorrect I/O port can lock up your machine.Files
/etc/rc.local /etc/rc.serialSee Also
tty(4), ttys(4), kernel/chr_drv/serial.cAuthor
The original version of setserial was written by Rick Sladkey ([email protected]), and wasmodified by Michael K. Johnson ([email protected]).This version has since been rewritten from scratch by Theodore Ts'o ([email protected]) on 1/1/93. Any bugs or problems are solely his responsibility.
Referenced By
cytune(8),slsnif(1),statserial(1),tcflush(3)OpenWrt the baud rate used by default is 115200,arduino serial port baud rate can set itself. Of course, it is generally set to 9600, or it can be set to 115200. Suppose now OpenWrt baud rate is 115200,arduino the serial port baud rate is 9600. How do I set up a communication?
First we need to use stty this software to change the baud rate on openwrt. Install Stty is very simple, opkg update software list, then opkg install Stty OK. After installation, use the command to change the baud rate: stty-f/dev/ttyath0 raw Speed 9600, so that the OpenWrt serial port baud rate to 9600.
Note that OpenWrt reboot after the serial port baud rate will be restored to 115200, we can write the above command into a shell script, add to the startup item, each boot automatically set serial port baud rate.
Here we look at how to send the data. OpenWrt sends a character ' a ' to the serial port, directly using echo ' a ' >/dev/ttyath0. Arduino over there using 1602 LCD display to receive the data. This shows the ASCII code of the character ' a ', not the real character ' a ', which needs to be converted to display as a. The Arduino code is:
Set serial port: Serial.begin (9600);
Setting 1602 LCD: lcd.setcursor (0, 0);
Monitor serial port and operate LCD:
if (serial.available ()) {Lcd.print (Serial.read ());}
First we need to use stty this software to change the baud rate on openwrt. Install Stty is very simple, opkg update software list, then opkg install Stty OK. After installation, use the command to change the baud rate: stty-f/dev/ttyath0 raw Speed 9600, so that the OpenWrt serial port baud rate to 9600.
Note that OpenWrt reboot after the serial port baud rate will be restored to 115200, we can write the above command into a shell script, add to the startup item, each boot automatically set serial port baud rate.
Here we look at how to send the data. OpenWrt sends a character ' a ' to the serial port, directly using echo ' a ' >/dev/ttyath0. Arduino over there using 1602 LCD display to receive the data. This shows the ASCII code of the character ' a ', not the real character ' a ', which needs to be converted to display as a. The Arduino code is:
Set serial port: Serial.begin (9600);
Setting 1602 LCD: lcd.setcursor (0, 0);
Monitor serial port and operate LCD:
if (serial.available ()) {Lcd.print (Serial.read ());}