@@ -68,12 +68,10 @@ func isWindows() bool {
6868 return runtime .GOOS == "windows"
6969}
7070
71- // getWindowsTimeout returns Windows-specific timeout values
72- func getWindowsTimeout () time.Duration {
73- if isWindows () {
74- return 100 * time .Millisecond // Increased for Windows stability
75- }
76- // Relax non-Windows default read timeout to improve reliability with USB-UART
71+ // getReadTimeout returns the unified read timeout for all platforms
72+ // Originally Windows needed 100ms while other platforms used 50ms, but Linux users
73+ // reported intermittent empty data issues, so we unified to 100ms for all platforms
74+ func getReadTimeout () time.Duration {
7775 return 100 * time .Millisecond
7876}
7977
@@ -96,9 +94,9 @@ func New(portName string) (*Transport, error) {
9694 return nil , fmt .Errorf ("failed to open UART port %s: %w" , portName , err )
9795 }
9896
99- // Set platform-specific timeout - increased for Windows due to driver differences
100- // 50ms proven to work on Linux/Mac, 100ms needed for Windows stability
101- timeout := getWindowsTimeout ()
97+ // Set unified read timeout - originally 50ms on Linux/Mac and 100ms on Windows,
98+ // but unified to 100ms on all platforms to resolve Linux USB-UART reliability issues
99+ timeout := getReadTimeout ()
102100 if err := port .SetReadTimeout (timeout ); err != nil {
103101 _ = port .Close ()
104102 return nil , fmt .Errorf ("failed to set UART read timeout: %w" , err )
0 commit comments