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

Commit

Permalink
Merge pull request #5 from localleon/sacn
Browse files Browse the repository at this point in the history
Sacn
  • Loading branch information
localleon authored May 10, 2018
2 parents 7db2ba1 + 316e684 commit fc6ce98
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions go/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"net/http"
"os"

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

"github.com/gorilla/mux"
"github.com/jacobsa/go-serial/serial"
)
Expand All @@ -19,6 +21,7 @@ var projAddr byte = 1
func main() {
portName := flag.String("serial", "COM4", "the identifier for the serial port")
baudRate := flag.Uint("baudrate", 115200, "the baudrate for the serial communication")
universe := flag.Uint("universe", 1, "the sACN universe to listen on")
showKeys := flag.Bool("showCmds", false, "if this flag is set, all possible CMD-DATA combinations are printed")

flag.Parse()
Expand Down Expand Up @@ -87,6 +90,20 @@ func main() {
*/
router.PathPrefix("/").Handler(http.StripPrefix("/", http.FileServer(http.Dir("static/"))))

recv := sacn.NewReceiver()
recv.Receive(uint16(*universe), "")
go func() {
for p := range recv.DataChan {
if p.Data()[0] == 255 {
writeCommand(port, "shutterclose", "fast")
log.Println("sACN: shutter closed")
} else if p.Data()[0] == 0 {
writeCommand(port, "shutteropen", "fast")
log.Println("sACN: shutter opened")
}
}
}()

log.Fatal(http.ListenAndServe(":8000", router))
}

Expand Down

0 comments on commit fc6ce98

Please sign in to comment.