From c05790901127b75e05b4ddafff88b4142fc43201 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Thu, 11 May 2017 21:15:00 +0200 Subject: [PATCH] firmata: return connect errors to client Signed-off-by: deadprogram --- platforms/firmata/client/client.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/platforms/firmata/client/client.go b/platforms/firmata/client/client.go index f1b820ee..5a759b4d 100644 --- a/platforms/firmata/client/client.go +++ b/platforms/firmata/client/client.go @@ -158,26 +158,27 @@ func (b *Client) Connect(conn io.ReadWriteCloser) (err error) { return ErrConnected } + var connectErr error b.connection = conn b.Reset() b.Once(b.Event("ProtocolVersion"), func(data interface{}) { - err := b.FirmwareQuery() - if err != nil { + connectErr = b.FirmwareQuery() + if connectErr != nil { b.setConnecting(false) } }) b.Once(b.Event("FirmwareQuery"), func(data interface{}) { - err := b.CapabilitiesQuery() - if err != nil { + connectErr = b.CapabilitiesQuery() + if connectErr != nil { b.setConnecting(false) } }) b.Once(b.Event("CapabilityQuery"), func(data interface{}) { - err := b.AnalogMappingQuery() - if err != nil { + connectErr = b.AnalogMappingQuery() + if connectErr != nil { b.setConnecting(false) } }) @@ -214,6 +215,9 @@ func (b *Client) Connect(conn io.ReadWriteCloser) (err error) { return default: + if connectErr != nil { + return connectErr + } break } }