rs8/cmd/log/log.go

36 lines
501 B
Go
Raw Normal View History

2024-03-30 18:31:00 +01:00
package main
import (
"github.com/rileys-trash-can/rs8"
2024-03-30 18:31:00 +01:00
"log"
"os"
)
func main() {
if len(os.Args) < 2 {
log.Fatalf("Usage: log <serial>")
}
port := os.Args[1]
conn, err := rs8.Open(port)
2024-03-30 18:31:00 +01:00
if err != nil {
log.Fatalf("Failed to connect: %s", err)
}
conn.InitBlynk()
ch := conn.ReadCh()
for {
e := <-ch
switch event := e.(type) {
case *rs8.EventButton:
2024-03-30 18:31:00 +01:00
log.Printf("%T %#v", event, event)
case *rs8.EventSlider:
2024-03-30 18:31:00 +01:00
log.Printf("%X %3d", event.Type, event.Value)
}
}
}