runtime: Linux: System.IO.Ports.SerialPort does not open with baudrate 111,865

area-System.IO

Description

We migrated a working console application from .Net 4.7.2 to .Net 7. The System.IO.Port.SerialPort gives an error with .Net 7 for the baud rate of 111,865. It works on Windows and macOS but does not work on Linux (x64, ARM64, ARM) anymore since the migration from .net 4.7.2 to .net 6. The error “Value does not fall within the expected range” is raised.

       var _sp = new SerialPort(
          "/dev/ttyS0",
          111865,
          0,
          8,
          StopBits.Two,
          Handshake.RequestToSend);
        _sp.Open();

Reproduction Steps

Attempt to open the serial port with the following on Linux

       var _sp = new SerialPort(
          "/dev/ttyS0",
          111865,
          0,
          8,
          StopBits.Two,
          Handshake.RequestToSend);
        _sp.Open();

Expected behavior

No error is thrown, and it works like all .Net Framework did (i.e. 4.7.2)

Actual behavior

An exception is raised for “Value does not fall within the expected range”

Regression?

.Net Framework 4.7.2

Known Workarounds

No response

Configuration

.net 7

Linux (ARM64, ARM, x64)

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

Do you have repro @janvorli or @krwq ? From the suggestions it seems like we do not try the BOTHER and we depend on IOSSIOSPEED.

The arm64 and x64 code base for mac w.r.t. the serial port handling is the same.