Custom device name for nrf52840 USB dongle in pyserial

I am making an application using nrf52840 USB dongle. 

I am using a python program with pyserial. This works great. 
My only problem is that I want to have a very reliable way to identify the correct USB device.

I am using this code in python to identify the USB device.

def find_nrf_com_port():
    ports = serial.tools.list_ports.comports()
    print("dY"? Available COM ports:")
    for port in ports:
        print(port)

    for port in ports:
        if "Nestlab" in port.description or "USB Serial Device" in port.description:
            return port.device
    return None


this is returning

PS C:\Users\BjornOlsen\Documents\GitHub\nestlab_usb_stick\usb_comm> python3 .\read_serial.py
🔍 Available COM ports:
COM17 - USB Serial Device (COM17)
✅ Auto-detected COM port: COM17
Connected to COM17...

The problem here is that the device is called "USB Serial Device". Not a very descriptive name! 

In my nrf52840 I am using this prj.conf.

CONFIG_GPIO=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Nestlab USB Stick"
CONFIG_USB_DEVICE_MANUFACTURER="Malsen Medical"
CONFIG_USB_DEVICE_SN="0001"
CONFIG_USB_CDC_ACM=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=y

CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

CONFIG_CJSON_LIB=y

I was expecting that this would change the name to "Nestlab USB Stick" - but alas this does not work.
Note! I do not need it to show up in windows. I only really need the name to be unique when I list USB devices using pyserial.


Parents Reply Children
  • Hello.


    Well I don't know what I am expected to see really.

    on windows the device shows up like this

    Get-WmiObject Win32_SerialPort | Where-Object { $_.PNPDeviceID -like 'USB*' } | Format-Table Name, DeviceID, PNPDeviceID, Description
    
    Name                      DeviceID PNPDeviceID                                   Description
    ----                      -------- -----------                                   -----------
    USB Serial Device (COM22) COM22    USB\VID_2FE3&PID_0100&MI_00\7&227FB56F&0&0000 USB Serial Device


    I don't want to mount the USB device to windows (I am not using it as a USB storage device). 
    I would expect that I would see the correct name in device manager. The name in the device manager is the same as what I see over python

    Device: COM22
     Name: COM22
     Description: USB Serial Device (COM22)
     HWID: USB VID:PID=2FE3:0100 SER=3702 LOCATION=1-2.2:x.0
     VID: 12259
     PID: 256
     Serial number: 3702
     Manufacturer: Microsoft
     Product: None

Related