Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
readLCD blocking added
Browse files Browse the repository at this point in the history
  • Loading branch information
Hundemeier committed May 10, 2018
1 parent fc6ce98 commit 23e778c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion go/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"net/http"
"os"
"time"

"github.com/Hundemeier/go-sacn/sacn"

Expand Down Expand Up @@ -133,7 +134,15 @@ type lcd struct {
Second string //`json:"second"`
}

var readLCDLock = false

func readLCD(port io.ReadWriteCloser) lcd {
for readLCDLock {
//wait unitl the lock is over
time.Sleep(10 * time.Millisecond)
}
readLCDLock = true

result := lcd{}
//Attemp to read the first line
writeBytes(port, createBytes(projAddr, []byte{0x7a, 0x02}, []byte{0, 0}))
Expand All @@ -156,7 +165,7 @@ func readLCD(port io.ReadWriteCloser) lcd {
break
}
}

readLCDLock = false
return result
}

Expand Down
1 change: 1 addition & 0 deletions go/static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function apirequest(cmd, opt) {
method: 'GET',
credentials: 'same-origin',
})
readLCD();
}

function readLCD() {
Expand Down

0 comments on commit 23e778c

Please sign in to comment.