Fetch status on startup
This commit is contained in:
parent
cb83de4bf5
commit
22315fbe47
1 changed files with 7 additions and 4 deletions
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue