Set COMx Port Permission Permanently Within WSL
Overview
If you are doing open source embedded work on Windows, most likely you are using Windows Subsystem for Linux (WSL). By default, WSL users do not have permission to use the COMx serial ports. The typical fix is to chmod the permission of the appropriate /dev/ttySx, but this does not survive a reboot.
Use Group Permission
I am using the USB Serial Cable from Adafruit to communicate with embedded devices. This device is based on the Silicon Labs CP210x. After making sure the driver is installed, you need to find out which COMx port Windows maps to your dongle. Within a Windows command prompt, you can type mode
and it will give you a list of all COMx ports. Unplug and plug in your cable and use this command to find which COMx port appears.
Within WSL (V1 only at the time of this writing), the /dev/ttySx
devices are mapped to the Windows COMx devices. By default, a user is not set up with the permission to use these devices. But instead of using chmod 666 /dev/ttySx
to set permission, which will not survive a reboot, instead you can add the dialout
group to your WSL user account.
Within a WSL command prompt, do the following:
$ whoami
chuckb
$ sudo usermod -a -G dialout chuckb
My username is chuckb. Replace mine with whatever shows up for yours.