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
[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