diff --git a/uncanny/can.go b/uncanny/can.go index 6faabb7..fda48d8 100644 --- a/uncanny/can.go +++ b/uncanny/can.go @@ -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: