We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fcf6b6d commit b63d152Copy full SHA for b63d152
serialport.go
@@ -95,13 +95,12 @@ type SpPortMessageRaw struct {
95
func (p *serport) reader() {
96
97
//var buf bytes.Buffer
98
+ ch := make([]byte, 1024)
99
timeCheckOpen := time.Now()
100
var buffered_ch bytes.Buffer
101
102
for {
103
- ch := make([]byte, 1024)
104
-
105
n, err := p.portIo.Read(ch)
106
107
//if we detect that port is closing, break out o this for{} loop.
@@ -128,9 +127,12 @@ func (p *serport) reader() {
128
127
for i, w := 0, 0; i < n; i += w {
129
runeValue, width := utf8.DecodeRune(ch[i:n])
130
if runeValue == utf8.RuneError {
131
- buffered_ch.Write(ch[i:n])
+ buffered_ch.Write(append(ch[i:n]))
132
break
133
}
+ if i == n {
134
+ buffered_ch.Reset()
135
+ }
136
data += string(runeValue)
137
w = width
138
0 commit comments