Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Detect Teensy 4.0 USB serial port

  1. #1

    Detect Teensy 4.0 USB serial port

    Is there some way of detecting which serial port is connected to the Teensy 4.0 on a Windows machine? I have the following Matlab code which gives me names for serial port devices. If I plug in an Arduino Leonardo, then this code lists its serial port name as "Arduino Leonardo" so I can easily use it. However, if i plug in a Teensy 2.0 and a Teensy 4.0, both serial ports are listed as "USB Serial Device", so I can't tell which device is which. Can I either change the serial port name or is there some other method for detecting which serial port is connected to the Teensy 4.0? I only have one Teensy 4.0 connected to the system.

    if err
    ports = [];
    ports = regexp(str,'\\Device\\(?<type>[^ ]*) *REG_SZ *(?<port>COM.*?)\n','names');
    cmd = 'REG QUERY HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\ /s /f "FriendlyName" /t "REG_SZ"';
    [~,str] = system(cmd);
    names = regexp(str,'FriendlyName *REG_SZ *(?<name>.*?) \((?<port>COM.*?)\)','names');
    [i,j] = ismember({ports.port},{names.port});
    [ports(i).name] = names(j(i)).name;

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Can you see the "Serial Number" field? That could be hardcoded?

    On Windows I found "USBDeview" { } and it shows this: Instance ID :: USB\VID_16C0&PID_0483\7684130

    That has the Teensy 4.1 VID and PID and finally the Serial Number - also available as sperate fields.

    Here is the same for a Teensy 4.0 - so it has a unique PID - but this is running DUAL SERIAL - so that may not be the
    Instance ID :: USB\VID_16C0&PID_048B\6362860

    Another Microsoft Tool "USB View" gives another look at the whole device info as well.

    For the T_4.1 it shows this as a HIGH speed device - as well as Vid and Pid:
    Device Descriptor:
    bcdUSB:             0x0200
    bDeviceClass:         0x02
    bDeviceSubClass:      0x00
    bDeviceProtocol:      0x00
    bMaxPacketSize0:      0x40 (64)
    idVendor:           0x16C0
    idProduct:          0x0483
    bcdDevice:          0x0280
    iManufacturer:        0x01
    0x0409: "Teensyduino"
    iProduct:             0x02
    0x0409: "USB Serial"
    iSerialNumber:        0x03
    0x0409: "7684130"
    bNumConfigurations:   0x01
    ConnectionStatus: DeviceConnected
    Current Config Value: 0x01
    Device Bus Speed:     High
    Device Address:       0x31
    Open Pipes:              3

  3. #3
    I can see the serial number! I found this article that had some code for changing the serial number, manufacturer name, and product name.

    I don't see how to read the manufacturer name and product name easily, but it looks like the serial number shows up at the end of the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum registry line

    Thanks so much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts