Re: pyserial.tools.list_port improvement for FreeBSD

From: Tomek CEDRO <tomek_at_cedro.info>
Date: Wed, 06 Nov 2024 11:08:09 UTC
Back to the topic hot :-)

There is this esptool for flashing ESP32 chips over UART.
`--port-filter` option was just added that can handle NAME and SERIAL
parameters of the USB dongles. New feature is released in 4.9.dev1 for
testing.. but it does not work on FreeBSD due current (3.5) pyserial
misses those parameters.

Here is the feature request for esptool:

https://github.com/espressif/esptool/issues/1027

This is the output of pyserial-ports --verbose on Linux:

(venv) ➜  esptool_test_freebsd pyserial-ports --verbose
/dev/ttyUSB0
    desc: CP2102N USB to UART Bridge Controller
    hwid: USB VID:PID=10C4:EA60 SER=7c98d1065267ee11bcc4c8ab93cd958c
LOCATION=3-6.1.7
/dev/ttyUSB1
    desc: CP2102N USB to UART Bridge Controller
    hwid: USB VID:PID=10C4:EA60 SER=14fefc9fe665ee119c09926293cd958c
LOCATION=3-6.1.5

This aligns well with Your patch PHK as tested before :-)

(venv3.9embedded) python3 list_ports.py -v
/dev/cuaU0
    desc: ugen0.7
    hwid: USB VID:PID=0483:374B SER="0667FF504955857567182143" LOCATION=ugen0.7
/dev/cuaU1
    desc: ugen0.8
    hwid: USB VID:PID=303A:1001 SER="60:55:F9:CC:E2:B8" LOCATION=ugen0.8
/dev/cuaU2
    desc: ugen0.9
    hwid: USB VID:PID=10C4:EA60 SER="1a2626680675eb11955981afb7be2ba5"
LOCATION=ugen0.9
/dev/cuau0
    desc: cuau0
    hwid: cuau0
4 ports found

Are those details propagated somewhere into pyserial core so other
places can use them too (i.e. for use with esptool)? Did you consider
replacing desc with name when possible? When do you plan to PR the
upstream? :-)

Thanks :-)
Tomek

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info