File tree 3 files changed +9
-5
lines changed
3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,13 @@ type BufferflowTimed struct {
18
18
19
19
var (
20
20
bufferedOutput string
21
+ sPort string
21
22
)
22
23
23
24
func (b * BufferflowTimed ) Init () {
24
25
log .Println ("Initting timed buffer flow (output once every 16ms)" )
25
26
bufferedOutput = ""
27
+ sPort = ""
26
28
27
29
go func () {
28
30
b .ticker = time .NewTicker (16 * time .Millisecond )
@@ -32,14 +34,16 @@ func (b *BufferflowTimed) Init() {
32
34
select {
33
35
case data := <- b .Input :
34
36
bufferedOutput = bufferedOutput + data
37
+ sPort = b .Port
35
38
case <- b .ticker .C :
36
39
if bufferedOutput != "" {
37
- m := SpPortMessage {bufferedOutput }
40
+ m := SpPortMessage {sPort , bufferedOutput }
38
41
buf , _ := json .Marshal (m )
39
42
// data is now encoded in base64 format
40
43
// need a decoder on the other side
41
44
b .Output <- []byte (buf )
42
45
bufferedOutput = ""
46
+ sPort = ""
43
47
}
44
48
case <- b .done :
45
49
break Loop
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ func (b *BufferflowTimedRaw) Init() {
32
32
b .ticker = time .NewTicker (16 * time .Millisecond )
33
33
for _ = range b .ticker .C {
34
34
if len (bufferedOutputRaw ) != 0 {
35
- m := SpPortMessageRaw {bufferedOutputRaw }
35
+ m := SpPortMessageRaw {b . Port , bufferedOutputRaw }
36
36
buf , _ := json .Marshal (m )
37
37
// data is now encoded in base64 format
38
38
// need a decoder on the other side
Original file line number Diff line number Diff line change @@ -83,12 +83,12 @@ type qwReport struct {
83
83
}
84
84
85
85
type SpPortMessage struct {
86
- // P string // the port, i.e. com22
86
+ P string // the port, i.e. com22
87
87
D string // the data, i.e. G0 X0 Y0
88
88
}
89
89
90
90
type SpPortMessageRaw struct {
91
- // P string // the port, i.e. com22
91
+ P string // the port, i.e. com22
92
92
D []byte // the data, i.e. G0 X0 Y0
93
93
}
94
94
@@ -157,7 +157,7 @@ func (p *serport) reader() {
157
157
158
158
if p .bufferwatcher .IsBufferGloballySendingBackIncomingData () == false {
159
159
//m := SpPortMessage{"Alice", "Hello"}
160
- m := SpPortMessage {data }
160
+ m := SpPortMessage {p . portConf . Name , data }
161
161
//log.Print("The m obj struct is:")
162
162
//log.Print(m)
163
163
You can’t perform that action at this time.
0 commit comments