Skip to content

[EDITOR-621] add port to serial output #616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bufferflow_timed.go
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion bufferflow_timedraw.go
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions serialport.go
Original file line number Diff line number Diff line change
@@ -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)