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 {
9595func (p * serport ) reader () {
9696
9797 //var buf bytes.Buffer
98+ ch := make ([]byte , 1024 )
9899 timeCheckOpen := time .Now ()
99100 var buffered_ch bytes.Buffer
100101
101102 for {
102103
103- ch := make ([]byte , 1024 )
104-
105104 n , err := p .portIo .Read (ch )
106105
107106 //if we detect that port is closing, break out o this for{} loop.
@@ -128,9 +127,12 @@ func (p *serport) reader() {
128127 for i , w := 0 , 0 ; i < n ; i += w {
129128 runeValue , width := utf8 .DecodeRune (ch [i :n ])
130129 if runeValue == utf8 .RuneError {
131- buffered_ch .Write (ch [i :n ])
130+ buffered_ch .Write (append ( ch [i :n ]) )
132131 break
133132 }
133+ if i == n {
134+ buffered_ch .Reset ()
135+ }
134136 data += string (runeValue )
135137 w = width
136138 }
You can’t perform that action at this time.
0 commit comments