Skip to content

Commit 906c87e

Browse files
committed
[WIN] avoid generating spurious USB transactions on Read() timeout
Fixes bcmi-labs/webide#2828
1 parent 8f8e4c0 commit 906c87e

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

seriallist.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ package main
44

55
import (
66
"fmt"
7-
log "github.com/Sirupsen/logrus"
8-
"go.bug.st/serial.v1/enumerator"
97
"regexp"
108
"strings"
9+
10+
log "github.com/Sirupsen/logrus"
11+
"go.bug.st/serial.v1/enumerator"
1112
)
1213

1314
type OsSerialPort struct {

vendor/go.bug.st/serial.v1/enumerator/usb_windows.go

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ func (dev *deviceInfo) openDevRegKey(scope dicsScope, hwProfile uint32, keyType
230230
}
231231

232232
func nativeGetDetailedPortsList() ([]*PortDetails, error) {
233+
233234
guids, err := classGuidsFromName("Ports")
234235
if err != nil {
235236
return nil, &PortEnumerationError{causedBy: err}

vendor/go.bug.st/serial.v1/serial_windows.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (port *windowsPort) Close() error {
6262

6363
func (port *windowsPort) Read(p []byte) (int, error) {
6464
var readed uint32
65-
params := &dcb{}
65+
//params := &dcb{}
6666
ev, err := createOverlappedEvent()
6767
if err != nil {
6868
return 0, err
@@ -94,11 +94,14 @@ func (port *windowsPort) Read(p []byte) (int, error) {
9494
// a serial port is alive in Windows is to check if the SetCommState
9595
// function fails.
9696

97-
getCommState(port.handle, params)
98-
if err := setCommState(port.handle, params); err != nil {
99-
port.Close()
100-
return 0, err
101-
}
97+
// XXX: this function was causing spurious USB transactions;
98+
// the 16u2 on an Arduino UNO/Mega interprets these data and sends a \0 to the main processor
99+
100+
//getCommState(port.handle, params)
101+
//if err := setCommState(port.handle, params); err != nil {
102+
// port.Close()
103+
// return 0, err
104+
//}
102105
}
103106
}
104107

0 commit comments

Comments
 (0)