Teensy 4.1 Dual‑USB Serial: How Are COM Ports Assigned?

samm_flynn

Well-known member
Hi all,

I’m building a project around a Teensy 4.1 using its built‑in dual USB‑Serial (CDC) interfaces. On Windows (and other OSes), I see two COM ports pop up whenever I plug in the board—but the numbers (e.g. COM3/COM4, COM5/COM6, etc.) don’t always stay the same:

Sometimes the “first” port is COM3 and the “second” is COM4.

Other times, after unplugging/replugging or on a different PC, they swap or jump to COM7/COM8.

I’m concerned because the end users of my project won’t be familiar with COM‑port juggling.

Is there any documented rule or pattern (on Windows, macOS, Linux) for how these dual‑CDC ports are assigned?

If the assignment really is effectively “random” or uncontrolled by the Teensy, do I need to implement my own identification protocol (e.g. a startup handshake where each USB interface sends a distinct ID string) so my host software can reliably tell “Port A” from “Port B”?

Are there any best practices or driver settings (e.g. custom VID/PID pairs, serial‑number strings, or USB descriptors) I can use on the Teensy side to influence or fix the port ordering?

Any guidance or examples would be hugely appreciated—thanks!
 
I'm not sure of the answer to your question but I can confirm that dual serial mode can randomly assign COM ports. That's irritating for all the reasons you mentioned. You can't just tell people "the first com port generated is X and the second one Y" because windows gives no guarantees of the order. However, from my experience both MacOS and Linux can correctly enumerate the USB end points in the proper order every time. Windows was just developed by drunk garden gnomes.
 
I agree completely with CollinK's post (especially the identification of the drunk garden gnomes). What I've done is to tell those I'm mentoring to open the Windows Device Manager before plugging in the Teensy. Make sure that the section showing the COM ports is expanded. Watch that particular section while you you are plugging the Teensy in to see what specific new COM port numbers show up in the list.

Hope that helps !!

Mark J Culross
KD5RXT
 
Seems when a single USB is presented you get one COM#, then when set to Dual two new COM#'s show up ( at least on Windows ) and in unknown order/location. And each machine will associate them with different COM# numbers as Windows chooses to parse and associate them.

Using TyCommander is a good way to see BOTH and figure out which is which when they present output. Once associated on a machine they do seem to stick there in that order as Windows presents them.
 
Appreciate everyone for taking the time to share information.

Looks like the easiest way would be to send some data over each port whenever it USBSerialx.dtr() is changed.

I was hoping not to do it, because then I either have to poll it or change some core code if polling is to be avoided.
 
Back
Top