From 1b32e598713681cbac2986178ce88fe926d32190 Mon Sep 17 00:00:00 2001 From: Frank Palazzolo Date: Mon, 14 Nov 2022 08:58:11 -0500 Subject: [PATCH] Remove unnecessary code, originally for checking disconnects The old code is no more needed when using overlapped I/O, getOverlappedEvent() returns all required error codes. Calling getCommState()/setCommState() every second in some applications contributes to other downstream issues. For examples: https://github.com/bugst/go-serial/issues/60#issuecomment-625749122 https://github.com/arduino/arduino-ide/issues/375 --- serial_windows.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/serial_windows.go b/serial_windows.go index 4b652b5..96b021c 100644 --- a/serial_windows.go +++ b/serial_windows.go @@ -114,17 +114,6 @@ func (port *windowsPort) Read(p []byte) (int, error) { return 0, nil } } - - // At the moment it seems that the only reliable way to check if - // a serial port is alive in Windows is to check if the SetCommState - // function fails. - - params := &dcb{} - getCommState(port.handle, params) - if err := setCommState(port.handle, params); err != nil { - port.Close() - return 0, err - } } }