Rick 0xfff
Rick 0xfff

Reputation: 226

Finding an active COM port from Ubuntu WSL (or probing the device registry from bash)

I want to programmatically discover the name of the serial port that a USB serial device is plugged into in Ubuntu WSL on Windows 10. For example, COM9 in Windows would correspond to /dev/ttyS9 in Ubuntu WSL.

From Windows 10,

reg query \HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM

So it seems like the way to do this would be to run the above query in a Bash-style command, assuming that the Windows registry is even visible to Ubuntu WSL. Is it?

Other dead-ends:

Unexplored:

Upvotes: 4

Views: 5735

Answers (1)

brucelsprouts
brucelsprouts

Reputation: 39

If you have the correct Port/Serial drivers installed (check device manager), then run:

for tty in $(ls /dev/ttyS*); do stty -F $tty -a; done

Any recongnized device will not show ... Input/output error

Upvotes: 3

Related Questions