dotnet/runtime

System.IO.Ports.SerialPort.Close() ignores disabled HUPCL flag on Linux

Open

#97,741 opened on 2024年1月31日

GitHub で見る
 (2 comments) (0 reactions) (0 assignees)C# (5,445 forks)batch import
area-System.IO.Portshelp wanted

Repository metrics

Stars
 (17,886 stars)
PR merge metrics
 (平均マージ 12d 11h) (30d で 661 merged PRs)

説明

Description

OS: DietPi arm64 bookworm on Raspberry Pi 4 Arduino connected via USB2 to the Pi

HUPCL (hang up on close) is disabled either by stty or a small Python program. When the serial port is closed using a .NET program, this is ignored and HUPCL is signaled leading to a reset of Arduino. Using the same with a Python program, HUPCL is not signaled on close.

Reproduction Steps

2 ways to disable HUPCL: stty -F /dev/ttyUSB0 -hupcl

or

small Python program: https://raspberrypi.stackexchange.com/a/31298

Minimal CLI program

var serialPort = new SerialPort("/dev/ttyUSB0") {
    ReadTimeout = 500,
    BaudRate = 250000,
    Parity = Parity.None,
    DataBits = 8,
    StopBits = StopBits.One,
    Handshake = Handshake.None,
    NewLine = "\r\n"
};
serialPort.Open();
serialPort.Close();

Expected behavior

  • HUPCL shall not be signaled an serialPort.Close();
  • A method to disable HUPCL using C#/.NET would be helpful

Actual behavior

HUPCL is signaled on serialPort.Close(); leading Arduino to reset

Regression?

No response

Known Workarounds

On Windows it is working as excpected.

Configuration

No response

Other information

No response

コントリビューターガイド