File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ func (communication *Communication) SendFrame(msg string) error {
92
92
93
93
func (communication * Communication ) sendFrame (msg string ) error {
94
94
dataLen := len (msg )
95
+ out := newBuffer ()
95
96
if dataLen == 0 {
96
97
return nil
97
98
}
@@ -103,8 +104,10 @@ func (communication *Communication) sendFrame(msg string) error {
103
104
buf .WriteByte (0xee )
104
105
}
105
106
x := buf .Bytes () // needs to be in a var: https://github.com/golang/go/issues/14210#issuecomment-346402945
106
- _ , err := communication .device .Write (x )
107
- return errp .WithMessage (errp .WithStack (err ), "Failed to send message" )
107
+ out .Write (x )
108
+ //_, err := communication.device.Write(x)
109
+ //return errp.WithMessage(errp.WithStack(err), "Failed to send message")
110
+ return nil
108
111
}
109
112
readBuffer := bytes .NewBufferString (msg )
110
113
// init frame
@@ -134,6 +137,14 @@ func (communication *Communication) sendFrame(msg string) error {
134
137
return err
135
138
}
136
139
}
140
+ for out .Len () > 0 {
141
+ x := out .Bytes ()
142
+ n , err := communication .device .Write (x )
143
+ if err != nil {
144
+ return errp .WithMessage (errp .WithStack (err ), "Failed to send message" )
145
+ }
146
+ out .Next (n )
147
+ }
137
148
return nil
138
149
}
139
150
You can’t perform that action at this time.
0 commit comments