Detect Teensy 4.0 USB serial port

Status
Not open for further replies.

geekEE

Active member
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.

[err,str] = system('REG QUERY HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM');
if err
ports = [];
else
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;
end
 
Can you see the "Serial Number" field? That could be hardcoded?

On Windows I found "USBDeview" { http://www.nirsoft.net/ } 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:
Code:
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
 
Status
Not open for further replies.
Back
Top