Skip to content

SerialPort error on Virtual Serial Port for USB LINUX #31523

@JTrotta

Description

@JTrotta

The problem should be related to the DTR setting. It cannot be done on virtual ports.

This is the error opening a /dev/ttyUSB7 port:
Hello World! Unhandled exception. System.IO.IOException: Broken pipe 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) at System.IO.Ports.SerialPort.Open() at RPTestcore3.Program.Start7() in D:\Visual Studio 2019\Projects\RPTestcore3\RPTestcore3\Program.cs:line 43 at RPTestcore3.Program.Main(String[] args) in D:\Visual Studio 2019\Projects\RPTestcore3\RPTestcore3\Program.cs:line 32 Aborted

The problem should be here:
internal SerialStream(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits, int readTimeout, int writeTimeout, Handshake handshake, bool dtrEnable, bool rtsEnable, bool discardNull, byte parityReplace)

at row568.
DtrEnable = dtrEnable;

which calls property:

internal bool DtrEnable
        {
            get
            {
                int status = Interop.Termios.TermiosGetSignal(_handle, Interop.Termios.Signals.SignalDtr);
                if (status < 0)
                {
                    throw GetLastIOError();
                }

                return status == 1;
            }

            set
            {
                if (Interop.Termios.TermiosGetSignal(_handle, Interop.Termios.Signals.SignalDtr, value ? 1 : 0) != 0)
                {
                    throw GetLastIOError();
                }
            }
        }`

We cannot set SignalDtr on Linux Virtual Ports.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions