I'm trying to test a program which should connect to some hardware through serial ports. I've built a "fake" hardware able to reproduce the real one.
Then i tried setting up some local port connection using tty0tty (i'm on Ubuntu) which gave me this :
(/dev/pts/1) <=> (/dev/pts/2)
However, when i tried to open the port on my test program like this :
var port = new ConcreteSerialPort("/dev/pts/2", 9600, Parity.None, 8, StopBits.One);
port.Open();
(ConcreteSerialPort is just an abstraction but all calls go directly to a real SerialPort.)
I get this exception :
Error : System.IO.IOException: Invalid argument
at System.IO.Ports.SerialStream.set_DtrEnable(Boolean value)
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)
What i already tried :
- Make a sudo chmod 777 /dev/pts/2
- Add port.DtrEnable = true; port.RtsEnable = true;
question from:
https://stackoverflow.com/questions/65881584/serialport-open-gives-exception-for-set-dtrenable 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…