diff --git a/adaptor.go b/adaptor.go index 7e55d75bf..893fc8533 100644 --- a/adaptor.go +++ b/adaptor.go @@ -4,6 +4,8 @@ type Adaptor interface { Finalize() []error Connect() []error Name() string +} + +type Porter interface { Port() string - String() string } diff --git a/connection.go b/connection.go index 16a5e745f..1c96dd52d 100644 --- a/connection.go +++ b/connection.go @@ -42,10 +42,13 @@ func (c *connections) Start() (errs []error) { log.Println("Starting connections...") for _, connection := range *c { info := "Starting connection " + connection.Name() - if connection.Port() != "" { - info = info + " on port " + connection.Port() + + if porter, ok := connection.(Porter); ok { + info = info + " on port " + porter.Port() } + log.Println(info + "...") + if errs = connection.Connect(); len(errs) > 0 { for i, err := range errs { errs[i] = errors.New(fmt.Sprintf("Connection %q: %v", connection.Name(), err)) diff --git a/device.go b/device.go index 7fec1da2e..adba5064d 100644 --- a/device.go +++ b/device.go @@ -52,9 +52,11 @@ func (d *devices) Start() (errs []error) { log.Println("Starting devices...") for _, device := range *d { info := "Starting device " + device.Name() - if device.Pin() != "" { - info = info + " on pin " + device.Pin() + + if piner, ok := device.(Piner); ok { + info = info + " on pin " + piner.Pin() } + log.Println(info + "...") if errs = device.Start(); len(errs) > 0 { for i, err := range errs { diff --git a/driver.go b/driver.go index 909af0306..2a206688e 100644 --- a/driver.go +++ b/driver.go @@ -4,7 +4,9 @@ type Driver interface { Start() []error Halt() []error Name() string - Pin() string - String() string Connection() Connection } + +type Piner interface { + Pin() string +}