This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-F280049C: Matching devices/serial numbers to COM ports

Part Number: LAUNCHXL-F280049C
Other Parts Discussed in Thread: UNIFLASH

Hi,

I have an application that communicates with multiple devices over serial, which currently uses the Python code below to find the appropriate COM ports:

command = 'wmic path Win32_SerialPort get Name | find /v "Name"'
        output = subprocess.check_output(command, shell=True, universal_newlines=True).splitlines()

        for line in output:
            if "Application/User UART" in line:
                num = line.split("(COM")[1].split(")")[0]
                devicelist.append(f"COM{num}")
This works great to grab all the devices and communicate in parallel, but we now want to also be able to call xdsdfu and uniflash via the CLI in Python to flash hex files to specific devices, as well as using the unique serial numbers of the devices to know which device is which (as the COM ports will change between computers). I initially tried using xdsdfu -e to read (and set custom) serial numbers, but I can't find a way to match these to a COM port so that I can also set up the serial communicaton.
Is there a command I'm missing, or some other tool available via the CLI, that I can use to find both the serial numbers and the associated COM ports, so that I can match these up?
Thanks,
Tom
  • Update - solved, using the code below:

    import serial.tools.list_ports as ls
    print([p.device for p in ls.comports()])
    print([p.serial_number for p in ls.comports()])

    the serial numbers match those given to the devices, even though I couldn't find them mentioned anywhere inside device manager and the device properties.