diff --git a/bufferflow_timed.go b/bufferflow_timed.go index c4a7b6117..248292208 100644 --- a/bufferflow_timed.go +++ b/bufferflow_timed.go @@ -18,11 +18,13 @@ type BufferflowTimed struct { var ( bufferedOutput string + sPort string ) func (b *BufferflowTimed) Init() { log.Println("Initting timed buffer flow (output once every 16ms)") bufferedOutput = "" + sPort = "" go func() { b.ticker = time.NewTicker(16 * time.Millisecond) @@ -32,14 +34,16 @@ func (b *BufferflowTimed) Init() { select { case data := <-b.Input: bufferedOutput = bufferedOutput + data + sPort = b.Port case <-b.ticker.C: if bufferedOutput != "" { - m := SpPortMessage{bufferedOutput} + m := SpPortMessage{sPort, bufferedOutput} buf, _ := json.Marshal(m) // data is now encoded in base64 format // need a decoder on the other side b.Output <- []byte(buf) bufferedOutput = "" + sPort = "" } case <-b.done: break Loop diff --git a/bufferflow_timedraw.go b/bufferflow_timedraw.go index 0c3acf7b8..b20f27f48 100644 --- a/bufferflow_timedraw.go +++ b/bufferflow_timedraw.go @@ -32,7 +32,7 @@ func (b *BufferflowTimedRaw) Init() { b.ticker = time.NewTicker(16 * time.Millisecond) for _ = range b.ticker.C { if len(bufferedOutputRaw) != 0 { - m := SpPortMessageRaw{bufferedOutputRaw} + m := SpPortMessageRaw{b.Port, bufferedOutputRaw} buf, _ := json.Marshal(m) // data is now encoded in base64 format // need a decoder on the other side diff --git a/serialport.go b/serialport.go index cad1a971d..c7e574a7a 100755 --- a/serialport.go +++ b/serialport.go @@ -83,12 +83,12 @@ type qwReport struct { } type SpPortMessage struct { - // P string // the port, i.e. com22 + P string // the port, i.e. com22 D string // the data, i.e. G0 X0 Y0 } type SpPortMessageRaw struct { - // P string // the port, i.e. com22 + P string // the port, i.e. com22 D []byte // the data, i.e. G0 X0 Y0 } @@ -157,7 +157,7 @@ func (p *serport) reader() { if p.bufferwatcher.IsBufferGloballySendingBackIncomingData() == false { //m := SpPortMessage{"Alice", "Hello"} - m := SpPortMessage{data} + m := SpPortMessage{p.portConf.Name, data} //log.Print("The m obj struct is:") //log.Print(m)