From 680b9d48c29eeae6f843e59316cfb39050c82c40 Mon Sep 17 00:00:00 2001 From: Gregor Riepl Date: Sun, 31 Jan 2021 18:37:47 +0100 Subject: [PATCH] Stop on all-off, more debugging --- uncanny/can.go | 6 ++++++ 1 file changed, 6 insertions(+) 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: