File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 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 {
9292
9393func (communication * Communication ) sendFrame (msg string ) error {
9494 dataLen := len (msg )
95+ out := newBuffer ()
9596 if dataLen == 0 {
9697 return nil
9798 }
@@ -103,8 +104,10 @@ func (communication *Communication) sendFrame(msg string) error {
103104 buf .WriteByte (0xee )
104105 }
105106 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
108111 }
109112 readBuffer := bytes .NewBufferString (msg )
110113 // init frame
@@ -134,6 +137,14 @@ func (communication *Communication) sendFrame(msg string) error {
134137 return err
135138 }
136139 }
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+ }
137148 return nil
138149}
139150
You can’t perform that action at this time.
0 commit comments