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 1 commit
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
Prev Previous commit
Next Next commit
fix port not being consistent (if more devices were connected)
  • Loading branch information
umbynos committed Feb 10, 2021
commit 4fc615a93c0a3784e24c12a8df7a1e901b5fd58e
5 changes: 4 additions & 1 deletion bufferflow_timed.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
func (b *BufferflowTimed) Init() {
log.Println("Initting timed buffer flow (output once every 16ms)")
bufferedOutput = ""
port = ""

go func() {
b.ticker = time.NewTicker(16 * time.Millisecond)
Expand All @@ -32,14 +33,16 @@ func (b *BufferflowTimed) Init() {
select {
case data := <-b.Input:
bufferedOutput = bufferedOutput + data
port = b.Port
case <-b.ticker.C:
if bufferedOutput != "" {
m := SpPortMessage{b.Port, bufferedOutput}
m := SpPortMessage{port, bufferedOutput}
buf, _ := json.Marshal(m)
// data is now encoded in base64 format
// need a decoder on the other side
b.Output <- []byte(buf)
bufferedOutput = ""
port = ""
}
case <-b.done:
break Loop
Expand Down