Problems of reading and writing to 2 connected serial ports under Linux

Source: Internet
Author: User

  To analyze the next Zmodem protocol, search found the tool under Linux Lrzsz is a tool containing x, Y, z modem transmission, download its source code, download. It can use a variety of serial interface for data transmission, such as the serial port, socket can also, this description seems inaccurate, but I found that in the CRT via SSH connection to Linux, can be used with SZ RZ to transfer files between Windows and Linux, speed can reach the M level, I began to think that only through the serial port transmission, the serial port obviously can not reach such a transmission rate, view the source code I found that it can be transmitted through the socket. After the modification of the source code inside the default standard input standard output to send and receive data through the specified serial port, so do not need the use of CRT tools, all the articles on the network are said through the CRT between Windows and Linux transfer files, and my idea is on 2 Linux machines, Through the serial port to communicate the Zmodem protocol, preferably streaming, rather than a file.


First I use VSPD this tool on Windows virtual out 2 connected serial port, that is, a serial port pair

Then connect the 2 serial ports on VMware, at this time for VMware, these 2 Windows serial port is 2 physical serial port, add serial device when the use physical serial port is selected. Once added, start the virtual system and connect the 2 serial devices. Then look at how the 2 serial ports are mapped in Linux and which device it is actually. Pass:

[Email protected] srv]# cat/proc/tty/driver/serial
serinfo:1.0 Driver Revision:
0:uart:16550a port:000003f8 irq:4 tx:1183731 rx:14614
1:uart:16550a port:000002f8 irq:3 tx:9721 rx:92472
2:uart:unknown Port:000003e8 Irq:4
3:uart:unknown Port:000002e8 Irq:3
[Email protected] srv]#

Can see only 0 and 1 is enabled, so is the ttys0,ttys1 corresponding to 2 serial ports, then verify that 2 serial ports are interconnected, in a terminal input:

Cat </DEV/TTYS0

Another terminal input:

echo "Test" >/dev/ttys1

If you receive the 2 serial port is connected.

Then I started writing a test program to read one of them, and I made a fairly low-level mistake, a special record. I still follow the way I read the files before, open---> select---> Fd_isset? ----> (read/write). The result is to write can succeed, collect that end of death can not receive, I obviously cat echo Test all succeeded!! Finally suddenly think of the serial port can communicate a most basic requirement is the same set of parameters, such as transceiver baud rate, data bit stop bit, and so on. So I set a pass after open, and it worked.

Problems of reading and writing to 2 connected serial ports under Linux

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.