[RK_2014_0904] test whether the serial port works normally in Linux. rk_2014_0904linux
I. Test Environment
PC1: Win8, run serial port debugging tool: USR-TCP232-Test.exe;
PC2: Ubuntu14.04;
"USB to serial port" is used between PC1 and PC2;
The USB to serial port uses the ftbench chip. For related drivers, please search for "ft232r usb uart" to download. Drivers for windows and linux are available. The chip manufacturer is FTDI.
The driver that comes with the ftbench chip in ubuntu14.04 is identified as:/dev/ttyUSB0.
Ii. Test serial port sending and receiving
1. [PC1-> PC2]
Open COM1 in the serial port debugging tool of PC1 and enter:
Hello, ubuntu14.04
And then send it cyclically.
Enter
# Cat/dev/ttyUSB0
If the serial port works normally, the following information will be displayed on the PC2 connector:
hello, ubuntu14.04hello, ubuntu14.04hello, ubuntu14.04hello, ubuntu14.04...
2. [PC2-> PC1]
Enter
Echo "hello, ubuntu14.04">/dev/ttyUSB0
If the serial port works properly, the following information is displayed in the receiving area of the serial port debugging assistant of pc1:
Hello, ubuntu14.04
Iii. Considerations
1. USB to serial port. The serial port name in Windows may be COM4 or COM5. Find the port in "Device Manager-> port (COM and LPT.
2. The serial port parameters at both ends must be consistent. If both ends are configured as "9600, N ".
How can I check whether the serial port is available in linux? Serial Port name?
Check whether the serial port is available. You can send data to the serial port, for example, to the com1 port, echo lyjie126>/dev/ttyS0
Check the serial port name using ls-l/dev/ttyS *. Generally, the serial port name is under dev. If you do not have an external serial port card, the default value is ttyS * under dev *, generally, ttyS0 corresponds to com1 and ttyS1 corresponds to com2, which is not necessarily inevitable;
View serial driver: cat/proc/tty/drivers/serial
View serial device: dmesg | grep ttyS *
In linux, how does one check whether a serial port is occupied? I tried to use multiple programs to open the same serial port.
Add the following sentence to the open function registered by the driver of the serial port:
Printk ("process % d has open tty \ n", current-> pid );
You can determine which process has enabled the serial port device, or whether a process has enabled the serial port. The value of current-> pid indicates the process number!