[Tips] under the shell to see if the serial port is working properly

Source: Internet
Author: User

Debugging a serial port under Linux is a hassle, especially in an embedded environment, and many times it is time to debug with another device.

Here to figure out a feasible serial debugging method, you can simply check whether the serial port is working correctly.

1. Short-Connect TX and RX (DB9 plug on the 2 and 3 feet, regardless of whether there is a crossover; Anyway, it's just 2 and 3 changed position, not affect this test)

2. Use "Cat/dev/ttyusb0 &" to monitor the output of the serial device/dev/ttyusb0 in the background

3. Use echo "Hello" >/dev/ttyusb0 to write data to the serial port, where the data is the string "Hello"

Thus, if the serial port is working properly, then after the execution of instruction 3, a Hello is printed on the screen, which is the self-receiving data of the serial port, and if the device is already dead, there will be no response.

If you want to further find out which pin the TX and RX of the serial port correspond to, you need another device.

However, there are multiple serial ports, we can use the above method: First use the above method to verify that two serial ports work properly, and then, respectively, two serial ports of 2 feet or 3 feet, to monitor one of the receiving (such as Ttyusb0,cat/dev/ttyusb0 &) , from another serial port to send a ttyusb1,echo (such as "Hello" >/dev/ttyusb1), if successfully received, then the ttyUSB1 side of the short wiring is the tx,ttyusb0 side of the RX; If unsuccessful, you can try other combinations and continue to verify.

[Tips] under the shell to see if the serial port is working properly

Related Article

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.