Skip to content

Commit b3860b0

Browse files
authored
[EDITOR-621] add port to serial output (#616)
* add port to serial output
1 parent 4e91762 commit b3860b0

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

bufferflow_timed.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ type BufferflowTimed struct {
1818

1919
var (
2020
bufferedOutput string
21+
sPort string
2122
)
2223

2324
func (b *BufferflowTimed) Init() {
2425
log.Println("Initting timed buffer flow (output once every 16ms)")
2526
bufferedOutput = ""
27+
sPort = ""
2628

2729
go func() {
2830
b.ticker = time.NewTicker(16 * time.Millisecond)
@@ -32,14 +34,16 @@ func (b *BufferflowTimed) Init() {
3234
select {
3335
case data := <-b.Input:
3436
bufferedOutput = bufferedOutput + data
37+
sPort = b.Port
3538
case <-b.ticker.C:
3639
if bufferedOutput != "" {
37-
m := SpPortMessage{bufferedOutput}
40+
m := SpPortMessage{sPort, bufferedOutput}
3841
buf, _ := json.Marshal(m)
3942
// data is now encoded in base64 format
4043
// need a decoder on the other side
4144
b.Output <- []byte(buf)
4245
bufferedOutput = ""
46+
sPort = ""
4347
}
4448
case <-b.done:
4549
break Loop

bufferflow_timedraw.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (b *BufferflowTimedRaw) Init() {
3232
b.ticker = time.NewTicker(16 * time.Millisecond)
3333
for _ = range b.ticker.C {
3434
if len(bufferedOutputRaw) != 0 {
35-
m := SpPortMessageRaw{bufferedOutputRaw}
35+
m := SpPortMessageRaw{b.Port, bufferedOutputRaw}
3636
buf, _ := json.Marshal(m)
3737
// data is now encoded in base64 format
3838
// need a decoder on the other side

serialport.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ type qwReport struct {
8383
}
8484

8585
type SpPortMessage struct {
86-
// P string // the port, i.e. com22
86+
P string // the port, i.e. com22
8787
D string // the data, i.e. G0 X0 Y0
8888
}
8989

9090
type SpPortMessageRaw struct {
91-
// P string // the port, i.e. com22
91+
P string // the port, i.e. com22
9292
D []byte // the data, i.e. G0 X0 Y0
9393
}
9494

@@ -157,7 +157,7 @@ func (p *serport) reader() {
157157

158158
if p.bufferwatcher.IsBufferGloballySendingBackIncomingData() == false {
159159
//m := SpPortMessage{"Alice", "Hello"}
160-
m := SpPortMessage{data}
160+
m := SpPortMessage{p.portConf.Name, data}
161161
//log.Print("The m obj struct is:")
162162
//log.Print(m)
163163

0 commit comments

Comments
 (0)