From 5dff2aa1697f21925365b8feacc058e0f3085260 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Mon, 7 Nov 2016 19:46:41 +0100 Subject: [PATCH] core: update Megapi platform to simply return error Signed-off-by: deadprogram --- platforms/megapi/megapi_adaptor.go | 12 ++++++------ platforms/megapi/motor_driver.go | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/platforms/megapi/megapi_adaptor.go b/platforms/megapi/megapi_adaptor.go index 6765c020..31c12ef2 100644 --- a/platforms/megapi/megapi_adaptor.go +++ b/platforms/megapi/megapi_adaptor.go @@ -42,11 +42,11 @@ func (megaPi *Adaptor) SetName(n string) { } // Connect starts a connection to the board -func (megaPi *Adaptor) Connect() (errs []error) { +func (megaPi *Adaptor) Connect() error { if megaPi.connection == nil { sp, err := serial.OpenPort(megaPi.serialConfig) if err != nil { - return []error{err} + return err } // sleeping is required to give the board a chance to reset @@ -69,15 +69,15 @@ func (megaPi *Adaptor) Connect() (errs []error) { } } }() - return + return nil } // Finalize terminates the connection to the board -func (megaPi *Adaptor) Finalize() (errs []error) { +func (megaPi *Adaptor) Finalize() error { megaPi.finalizeChannel <- struct{}{} <-megaPi.finalizeChannel if err := megaPi.connection.Close(); err != nil { - return []error{err} + return err } - return + return nil } diff --git a/platforms/megapi/motor_driver.go b/platforms/megapi/motor_driver.go index 56473717..b28c32c9 100644 --- a/platforms/megapi/motor_driver.go +++ b/platforms/megapi/motor_driver.go @@ -41,21 +41,21 @@ func (m *MotorDriver) SetName(n string) { } // Start implements the Driver interface -func (m *MotorDriver) Start() []error { +func (m *MotorDriver) Start() error { m.syncRoot.Lock() defer m.syncRoot.Unlock() m.halted = false m.speedHelper(0) - return []error{} + return nil } // Halt terminates the Driver interface -func (m *MotorDriver) Halt() []error { +func (m *MotorDriver) Halt() error { m.syncRoot.Lock() defer m.syncRoot.Unlock() m.halted = true m.speedHelper(0) - return []error{} + return nil } // Connection returns the Connection associated with the Driver