- Home /
Question by
zammle2009wtf · Nov 30, 2020 at 03:07 PM ·
c#linuxusbserialport
Unity - IOException: SerialPort.Open()
So I am trying to open a Serial Port on unity so I can read data.
However, the new USB device I'm trying to read from has been giving me issues unlike previous.
IOException: Invalid argument
System.IO.Ports.SerialPortStream.ThrowIOException () (at <aa976c2104104b7ca9e1785715722c9d>:0)
System.IO.Ports.SerialPortStream..ctor (System.String portName, System.Int32 baudRate, System.Int32 dataBits, System.IO.Ports.Parity parity, System.IO.Ports.StopBits stopBits, System.Boolean dtrEnable, System.Boolean rtsEnable, System.IO.Ports.Handshake handshake, System.Int32 readTimeout, System.Int32 writeTimeout, System.Int32 readBufferSize, System.Int32 writeBufferSize) (at <aa976c2104104b7ca9e1785715722c9d>:0)
(wrapper remoting-invoke-with-check)System.IO.Ports.SerialPortStream..ctor(string,int,int,System.IO.Ports.Parity,System.IO.Ports.StopBits,bool,bool,System.IO.Ports.Handshake,int,int,int,int)
System.IO.Ports.SerialPort.Open () (at <aa976c2104104b7ca9e1785715722c9d>:0)
(wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort.Open()
Never got this error before when opening other USB serial ports.
using System.IO.Ports;
void Start()
{
stream = new SerialPort("/dev/usb/hiddev0",256000,Parity.None, 8 ,StopBits.One);
stream.WriteTimeout = 300;
stream.ReadTimeout = 5000;
stream.DtrEnable = true;
stream.RtsEnable = true;
stream.Open()
}
I tried to change syntax but haven't gotten a successful open()
.
Comment