System.IO.Ports.SerialPort.Close() ignores disabled HUPCL flag on Linux
#97.741 geöffnet am 31. Jan. 2024
Repository-Metriken
- Stars
- (17.886 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 12T 11h) (661 gemergte PRs in 30 T)
Beschreibung
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