https://bugs.winehq.org/show_bug.cgi?id=57399
Bug ID: 57399 Summary: [wine-mono] ReadTimeout of SerialPort not working properly Product: Wine Version: 9.20 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: serial Assignee: wine-bugs@winehq.org Reporter: osu_Vanilla@126.com Distribution: ---
The following code set ReadTimeout to 500ms, and call the function Read. When COM33 receives nothing, it should throw TimeoutException after timeout.
But wine stuck on the Read operation, until it received 4096 (or more) bytes.
``` using System.IO.Ports;
namespace ConsoleApplication1 { internal class Program { public static void Main(string[] args) { var serialPort = new SerialPort("COM33", 9600, Parity.None, 8, StopBits.One); serialPort.ReadTimeout = 500; serialPort.WriteTimeout = 500; serialPort.Open(); var buff = new byte[4096]; serialPort.Read(buff, 0, 4096); } } } ```
https://bugs.winehq.org/show_bug.cgi?id=57399
--- Comment #1 from osu_Vanilla@126.com --- btw, my COM33 links to /dev/ttyUSB0, which is a CH340 USB serial converter. Also, the SerialPort is from wine-mono, I compile the code with mono, target 4.0.
Actually, I found wine bug #52340, which shows SerialPort implement uses corefx: https://github.com/madewokherd/mono/pull/22. FYI, revert the commit will not help.
https://bugs.winehq.org/show_bug.cgi?id=57399
--- Comment #3 from osu_Vanilla@126.com --- I compile the program on Windows, with .NET 8.0 and System.IO.Ports from NuGet (https://www.nuget.org/packages/system.io.ports), then install dotnet-runtime-8.0.10-win-x64.exe with a clean wine to run the program.
Unluckily, it still waiting for serial port input infinity, no TimeoutException throws after 500ms.