CM3-Panel-7-poe technical documentation Buy

How to configure serial port adapters on the USB port (Multiple Hub)

With this process we will always use this USB port for this device.

Now we connect the serial port adapter, and run command:

$ lsusb

Result:

Bus 001 Device 006: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
Bus 001 Device 008: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 005: ID 2109:2813 VIA Labs, Inc. 
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

This ID is the serial port adapter where, 067b is idVendor and the second number 2303 is idProduct.

Launch this command:

$ udevadm info /dev/ttyUSB0 | grep "ID_PATH="

Result:

pi@panel7:~/app $ udevadm info /dev/ttyUSB0 | grep "ID_PATH="
E: ID_PATH=platform-3f980000.usb-usb-0:1.4.2:1.0

The string "platform-3f980000.usb-usb-0:1.4.2:1.0" must be inserted into a file through this command:

$ sudo nano /etc/udev/rules.d/99-usb-serial.rules

This is content:

ENV{ID_PATH}=="platform-3f980000.usb-usb-0:1.4.2:1.0", SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK+="ttyS01", GROUP="dialout", MODE="0666"

Now disconnect the adapter and reconnect to the same port.

Now we’ll have a new serial device called /dev/ttyS01.

To view this test more quickly, we can use this Python script:

Run command:

$ pip install termcolor

Launch this command:

$ nano /home/app/serialmonitor.py

Insert:

#!/usr/bin/python

import time
import os
import serial.tools.list_ports as ports
from termcolor import colored, cprint   # ( Require --> pip install termcolor )


while True:
    time.sleep(.2)

    os.system("clear")

    print "===================================================================="
    cprint(' FIX SERIAL USB ADAPTER - PORT MONITOR', 'blue', attrs=['bold', 'blink'])
    print "===================================================================="

    ser_ports = list(ports.comports()) # List serial port

    cprint('\nUSB Serial Port device:', 'blue', attrs=['bold', 'blink'])

    for i in ser_ports:    
        vn = i.device
        p = time.strftime("%Y-%m-%d %H:%M:%S") + "\t" + vn

        if ( vn.find('ttyS') > 0 ):
            cprint(p + ' - (Use this port)', 'green', attrs=['bold'])
        else:
            cprint(p, 'red', attrs=['bold'])


    cprint('\nSimlink Serial Port:', 'yellow', attrs=['bold', 'blink'])
    os.system("ls -la /dev/tty* | grep \" ->\"")

    time.sleep(.2)

Run this command:

$ chmod +x /home/pi/serialmonitor.py

Now, to run the script run the following command:

$ ./home/pi/serialmonitor.py

Result:

====================================================================
 FIX SERIAL USB ADAPTER - PORT MONITOR
====================================================================

USB Serial Port device:
2021-09-14 16:30:33  /dev/ttyS01 - (Use this port)
2021-09-14 16:30:33  /dev/ttyUSB0
2021-09-14 16:30:33  /dev/ttyAMA0

Simlink Serial Port:
lrwxrwxrwx 1 root root          7 Sep 14 16:30 /dev/ttyS01 -> ttyUSB0

Home page CM3-Panel-7-poe technical documentation Buy