0

I want to use a Teensyduino 3.2 for reading Serial input from my python program. The python program uses the "serial.tools.list_ports" library to automatically detect Arduinos that are connected via USB with this simple code:

#____________finding Arduino COM Ports______________

ports = list(ser.comports())

for p in ports:
    print(p)
    if "Arduino" in p.description:
        x = str(p)
        arduinoCOM = x[:5]

        print("")
        print("____________________________")
        print("Arduino found! arduinoPort:")
        print(arduinoCOM)
        print("____________________________")
        print("")

Output of python program:

OM4 - USB Serial Device (COM4)
COM8 - Standard Serial over Bluetooth link (COM8)
COM51 - Arduino Uno (COM51)

____________________________
Arduino found! arduinoPort:
COM51
____________________________

COM7 - Standard Serial over Bluetooth link (COM7)
COM5 - USB Serial Device (COM5)
COM3 - Intel(R) Active Management Technology - SOL (COM3)

This works fine for any Arduino Boards because they're connection shows up as, for example: "Arduino Uno (COM51)" as shown in the Device Manager: Device Manager Snipping Tool.png

But the Teensy (blue Highlighted) only shows up as: "USB Serial Device (COM14)". Like this, my python code cant differentiate any USB device from the Teensyduino.

How can i rename the connection with my Teensyduino to for example: "Teensyduino 3.2 (COM14)?

What i have already tried:

https://medium.com/@j0hnm4r5/changing-teensy-serial-name-and-port-name-2ca76552d26d https://www.youtube.com/watch?v=nrT7WXFEEZI

Thank you very much in advance!

Kind regards Liamzgi

  • 1
    There is a related question on teensy's own forum: https://forum.pjrc.com/threads/25295-Automatically-find-a-Teensy-Board-with-Python-and-PySerial – Lanting Aug 30 '21 at 12:18

1 Answers1

0

The comports() method returns a list of ListPortInfo objects.

Instead of checking if the description contains the name 'Arduino', you can use the vid and pid members to see if those match those of the teensy bootloader (which you can copy from the properties you find in the windows device manager). The ListPortInfo also contains a number of other fields (such as a manufacturer field) which you can possibly use as well.

Lanting
  • 3,060
  • 12
  • 28