Skip to content

Commit 3acc34a

Browse files
committed
Merge pull request #26 from arduino/timed
Cleanup output
2 parents 4f37be8 + 74ce364 commit 3acc34a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

bufferflow_timed.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package main
22

33
import (
44
"encoding/json"
5-
log "github.com/Sirupsen/logrus"
65
"time"
6+
7+
log "github.com/Sirupsen/logrus"
78
)
89

910
type BufferflowTimed struct {
@@ -31,10 +32,12 @@ func (b *BufferflowTimed) Init() {
3132
go func() {
3233
b.ticker = time.NewTicker(16 * time.Millisecond)
3334
for _ = range b.ticker.C {
34-
m := SpPortMessage{bufferedOutput}
35-
buf, _ := json.Marshal(m)
36-
b.Output <- []byte(buf)
37-
bufferedOutput = ""
35+
if bufferedOutput != "" {
36+
m := SpPortMessage{bufferedOutput}
37+
buf, _ := json.Marshal(m)
38+
b.Output <- []byte(buf)
39+
bufferedOutput = ""
40+
}
3841
}
3942
}()
4043

0 commit comments

Comments
 (0)