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