Skip to content

Commit 895d9d2

Browse files
committed
Revert "fix stupid bug on serial buffering routine"
This reverts commit 616d5aa. Revert "try to avoid out-of-bound read on abrupt serial event" This reverts commit 0e65d13. Revert "Append buffered bytes only if read() was successful" This reverts commit 72bcdc1.
1 parent 616d5aa commit 895d9d2

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

serialport.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,6 @@ func (p *serport) reader() {
103103

104104
n, err := p.portIo.Read(ch)
105105

106-
if err == nil {
107-
if n > len(ch) {
108-
n = len(ch)
109-
}
110-
ch = append(buffered_ch.Bytes(), ch[:n-1]...)
111-
n += len(buffered_ch.Bytes())
112-
buffered_ch.Reset()
113-
}
114-
115106
//if we detect that port is closing, break out o this for{} loop.
116107
if p.isClosing {
117108
strmsg := "Shutting down reader on " + p.portConf.Name
@@ -120,6 +111,10 @@ func (p *serport) reader() {
120111
break
121112
}
122113

114+
ch = append(buffered_ch.Bytes(), ch[:n]...)
115+
n += len(buffered_ch.Bytes())
116+
buffered_ch.Reset()
117+
123118
// read can return legitimate bytes as well as an error
124119
// so process the bytes if n > 0
125120
if n > 0 {

0 commit comments

Comments
 (0)