runtime: Unknown error 203 while reading from serial port on Debian (WSL)
Hello,
I am trying to write a simple console application to read data from USB device available through COM5. When I am trying to run the code under Windows 10 everything working fine. However I am getting some strange error when trying to run the code under Debian 10 (WSL). Here is a code:
port.Open();
var buf = new byte[5];
var l = port.BaseStream.Read(buf, 0, 5);
Console.WriteLine("Bytes read: ", l);
Console.WriteLine("Content: ", BitConverter.ToString(buf).Replace("-",""));
port.Close();
After running this code I am always see:
Unhandled exception. System.UnauthorizedAccessException: Access to the port ‘/dev/ttyS5’ is denied. —> System.IO.IOException: Unknown error 203 — End of inner exception stack trace — at System.IO.Ports.SafeSerialDeviceHandle.Open(String portName) at System.IO.Ports.SerialStream…ctor(String portName, Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32 readTimeout, Int32 writeTimeout, Handshake handshake, Boolean dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace) at System.IO.Ports.SerialPort.Open() at hello_serialport.Program.Main(String[] args)
I’ve tried all possible combinations with permissions to COM port, added myself to dialout group, etc… nothing is working. I am pretty sure that issue is not related with accessing the COM port through WSL, because have a python script which can read everything from the same port without any issues.
Any ideas why this might happens?
/Alexander
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 28 (20 by maintainers)
I am using RPi at home and not always have access to it, since traveling my my laptop. I just wanted to have some kind of Linux testing environment, so decided that wsl would be a good idea