dotnet/runtime

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

Open

#97,741 建立於 2024年1月31日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)C# (5,445 fork)batch import
area-System.IO.Portshelp wanted

倉庫指標

Star
 (17,886 star)
PR 合併指標
 (平均合併 12天 11小時) (30 天內合併 661 個 PR)

描述

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

貢獻者指南