Skip to content

Commit 95de9d6

Browse files
committed
Solve serial crash (again)
1 parent 895d9d2 commit 95de9d6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

serialport.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ func (p *serport) reader() {
111111
break
112112
}
113113

114-
ch = append(buffered_ch.Bytes(), ch[:n]...)
115-
n += len(buffered_ch.Bytes())
116-
buffered_ch.Reset()
114+
if err == nil {
115+
ch = append(buffered_ch.Bytes(), ch[:n]...)
116+
n += len(buffered_ch.Bytes())
117+
buffered_ch.Reset()
118+
}
117119

118120
// read can return legitimate bytes as well as an error
119121
// so process the bytes if n > 0

0 commit comments

Comments
 (0)