First, view the serial port information of the machine

 

1. Is the serial port in use?

The serial port is in the / dev directory. To see if the serial port is in use, you can use the command

 ls -l /dev/ttyUSB0

 

 

Note:
ls -l: command to view the directory, you can also use ls or ll directly.
ttyUSB0: It is the name of the serial port. Generally it starts with tty. Depending on the connected device, some serial ports are named ttyS0, some are ttyACM0, and the following 0 is the serial port number. Change it according to your needs.

Result:
If it is in use, it will display the serial file information . If it is
not in use, it will display “ls: cannot access ‘/ dev / ttyUSB0’: no ​​such file or directory”

2. View the serial device
dmesg | grep ttyUSB0

 

Serial debugging software

There are a lot of serial debugging software under Windows, and relatively few resources under Linux, but there are a few useful ones.

 

Minicom

I heard that it is very powerful, but it does not have a UI interface, and it is not easy to use at first.
installation:

sudo apt install minicom

 

 

The specific usage is not very proficient, we will make up later.
Previous image:
Operation_of_the_serial_port_in_Ubuntu_2.png

 

2. CuteCom

This is more friendly and has an interface. Similar to Windows, you can choose the serial port, set the baud rate, data bits, stop bits, etc.
In the middle is the receive window, and below is the send window.
installation:

# 安装
sudo apt install cutecom 
# 启动
sudo cutecom

 

 

 

 

 

To the picture:
Operation_of_the_serial_port_in_Ubuntu_3.png

 

3. COMTool

This is found on github, developed by Neucrack Neutree, and developed with python3. Please note that your computer cannot run without Python3. It is worth noting that it supports cross-platform, linux, windows, mac can be used.

GitHub link

GitHub has installation and use tutorials for each platform.
Operation_of_the_serial_port_in_Ubuntu_4.png

 

Third, serial port permissions

The Linux serial port has no read and write permissions by default. Every time you boot, you must add permissions to the serial port.

sudo chmod 666 /dev/ttyUSB0

 

 

However, it is troublesome for programs that need to be started automatically on startup, so you can set a permanent weight

  1. Open the file below. If you are
    remote, change gedit to vi or nano.
    This file does not exist, but the editor will automatically create a file that does not exist.
    70-usb-serial.rules file name can be customized, but must end with .rules.
sudo gedit /etc/udev/rules.d/70-usb-serial.rules

 

 

  1. Add the following content to the file:
    ttyUSB * means all the serial port names in this format. If you have ttyS * or others, change them as needed.
    0666 indicates the weighting mode, which is the same as the parameter behind chmod. It can also be written as 666.
    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 remove the last item.
KERNEL=="ttyUSB*", MODE="0666", SYMLINK+="vibot_base"

 

 

Operation_of_the_serial_port_in_Ubuntu_5.png

  1. Restart the computer
    Restart the computer for the changes to take effect.

Article last posted at: 2019-11-25 18:25:33

Orignal link:https://blog.csdn.net/maizousidemao/article/details/103236666