Skip to content

Commit 4fc615a

Browse files
committed
fix port not being consistent (if more devices were connected)
1 parent 59e009d commit 4fc615a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

bufferflow_timed.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var (
2323
func (b *BufferflowTimed) Init() {
2424
log.Println("Initting timed buffer flow (output once every 16ms)")
2525
bufferedOutput = ""
26+
port = ""
2627

2728
go func() {
2829
b.ticker = time.NewTicker(16 * time.Millisecond)
@@ -32,14 +33,16 @@ func (b *BufferflowTimed) Init() {
3233
select {
3334
case data := <-b.Input:
3435
bufferedOutput = bufferedOutput + data
36+
port = b.Port
3537
case <-b.ticker.C:
3638
if bufferedOutput != "" {
37-
m := SpPortMessage{b.Port, bufferedOutput}
39+
m := SpPortMessage{port, bufferedOutput}
3840
buf, _ := json.Marshal(m)
3941
// data is now encoded in base64 format
4042
// need a decoder on the other side
4143
b.Output <- []byte(buf)
4244
bufferedOutput = ""
45+
port = ""
4346
}
4447
case <-b.done:
4548
break Loop

0 commit comments

Comments
 (0)