1. View the serial port information
1. Check whether the serial port is in use
The serial port is in the /dev directory. You can run a command to check whether the serial port is in use
ls -l /dev/ttyUSB0
Copy the code
Note: ls -l: indicates the command to view the directory. You can also run ls or ll directly. TtyUSB0: indicates the serial port name, which usually starts with tty. Some serial ports are named ttyS0 or ttyACM0 depending on the connected device. The 0 is the serial port number.
Results:
If the serial port file is in use, the serial port file information is displayed
‘ls: unable to access ‘/dev/ttyUSB0′: no file or directory’
2. View the serial port device
dmesg | grep ttyUSB0
Copy the code
Two, serial port debugging software
There are many serial debugging software under Windows, and relatively few resources under Linux, but there are also a few good to use.
1. minicom
I hear it’s very powerful, but it doesn’t have a UI, so it’s not easy to use at first. Installation:
sudo apt install minicom
Copy the code
The specific usage is not very skilled, later to fill. On a graph:
2. CuteCom
This is a little bit friendlier. It has an interface. Similar to Windows, you can select the serial port, set baud rate, data bit, stop bit, etc. In the middle is the receive window, and below is the send window. Installation:
# installation
sudo apt install cutecom
# start
sudo cutecom
Copy the code
To picture:
3. COMTool
This one is found on Github, developed by Neucrack Neutree, using Python3, but it’s important to note that your computer won’t work without Python3. Notably, it is cross-platform, working on Linux, Windows, and MAC.
Making a link
Github has tutorials for installing and using each platform.
3. The serial port permission is incorrect
By default, common users do not have read and write permissions on the Linux serial port. After startup, they must attach the read and write permissions to the serial port
sudo chmod 666 /dev/ttyUSB0
Copy the code
But for the need to boot automatically run the program is very troublesome, so you can set permanent weighting
- Open the following file
For remote use, change gedit to VI or Nano. This file does not exist, but it is automatically created when the editor opens a file that does not exist. 70- USB-serial. rules The file name can be customized, but must end with. Rules.
sudo gedit /etc/udev/rules.d/70-usb-serial.rules
Copy the code
- Add the following content to the file
TtyUSB * indicates all serial port names in this format. If yours is ttyS* or something else, change as needed. 0666 indicates the weighted mode, which is the same as chmod. 666 is also acceptable. Vibot_base is my custom serial port name, which is to create a hyperlink for ttyUSB*, as shown below. If you don’t need it, you can get rid of the last term.
KERNEL=="ttyUSB*", MODE="0666", SYMLINK+="vibot_base"
Copy the code
- Restart the computer
Restart the computer for the changes to take effect.