dotnet/runtime
在 GitHub 查看System.IO.Ports.SerialPort.Close() ignores disabled HUPCL flag on Linux
Open
#97,741 创建于 2024年1月31日
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