diff --git a/uncanny/can.go b/uncanny/can.go index 5fbdaf1..6faabb7 100644 --- a/uncanny/can.go +++ b/uncanny/can.go @@ -28,8 +28,9 @@ func NewCan(intf string) (*Can, error) { func (c *Can) Start() { go func() { - // send the init sequence - c.initialize() + // send the init sequence, but (hopefully) defer until after we start listening + // FIXME this is inherently racy :( + go c.initialize() // ConnectAndPublish will block, so we'll just leave the Printf hanging here log.Printf("CAN bus shut down: %v", c.bus.ConnectAndPublish()) }() @@ -113,7 +114,9 @@ func (c *Can) Cancel() error { return c.bus.Publish(DispenseMessage{DispenseSlotOff}.Encode()) } -func (c *Can) initialize() error { +func (c *Can) initialize() { // enable automatic status updates - return c.bus.Publish(AutoMessage{true}.Encode()) + c.bus.Publish(AutoMessage{true}.Encode()) + c.bus.Publish(RequestFeedbackMessage()) + c.bus.Publish(RequestPowerMessage()) }