Stop on all-off, more debugging

This commit is contained in:
Gregor Riepl 2021-01-31 18:37:47 +01:00
parent 22315fbe47
commit 680b9d48c2

View file

@ -53,7 +53,13 @@ func (c *Can) Handle(frame can.Frame) {
switch typ {
case MessageTypeFeedback:
log.Printf("Got feedback message: %+v", obj.(FeedbackMessage))
log.Printf("Data: 0x%02x 0x%02x", frame.Data[0], frame.Data[1])
c.swstate = obj.(FeedbackMessage)
// when all end switches are off: send stop command
if !c.swstate.EmptyD && !c.swstate.EmptyE && !c.swstate.EmptyF && !c.swstate.EmptyG && !c.swstate.EmptyH {
log.Printf("All end switches off, stopping dispenser")
c.Cancel()
}
case MessageTypeFeedbackRequest:
// ignore
case MessageTypePower: