File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -95,13 +95,12 @@ type SpPortMessageRaw struct {
95
95
func (p * serport ) reader () {
96
96
97
97
//var buf bytes.Buffer
98
+ ch := make ([]byte , 1024 )
98
99
timeCheckOpen := time .Now ()
99
100
var buffered_ch bytes.Buffer
100
101
101
102
for {
102
103
103
- ch := make ([]byte , 1024 )
104
-
105
104
n , err := p .portIo .Read (ch )
106
105
107
106
//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
128
runeValue , width := utf8 .DecodeRune (ch [i :n ])
130
129
if runeValue == utf8 .RuneError {
131
- buffered_ch .Write (ch [i :n ])
130
+ buffered_ch .Write (append ( ch [i :n ]) )
132
131
break
133
132
}
133
+ if i == n {
134
+ buffered_ch .Reset ()
135
+ }
134
136
data += string (runeValue )
135
137
w = width
136
138
}
You can’t perform that action at this time.
0 commit comments