From 204a63a9b8105ec9b94d4549fc0e33db422085d9 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Fri, 18 Aug 2023 17:51:19 +0200 Subject: [PATCH] update gomavlib (#42) --- go.mod | 2 +- go.sum | 4 ++-- main_test.go | 18 ++++++++++++------ message_handler.go | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 64b1a75..e253e8d 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/alecthomas/kong v0.8.0 - github.com/bluenviron/gomavlib/v2 v2.0.4 + github.com/bluenviron/gomavlib/v2 v2.1.0 github.com/stretchr/testify v1.8.4 ) diff --git a/go.sum b/go.sum index 1a2d6fe..556c3cc 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/alecthomas/assert/v2 v2.1.0 h1:tbredtNcQnoSd3QBhQWI7QZ3XHOVkw1Moklp2o github.com/alecthomas/kong v0.8.0 h1:ryDCzutfIqJPnNn0omnrgHLbAggDQM2VWHikE1xqK7s= github.com/alecthomas/kong v0.8.0/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U= github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE= -github.com/bluenviron/gomavlib/v2 v2.0.4 h1:fXi4xY41Nk9avDdcb7/uqT5qu3QEwiSUfifUFzH5KZg= -github.com/bluenviron/gomavlib/v2 v2.0.4/go.mod h1:omnSr00XvG6HVnDSM1vYgnvsVD/ihoPSV84cv/Km7rA= +github.com/bluenviron/gomavlib/v2 v2.1.0 h1:Tilg+YJq98NjL8vYI7m0DarNyEl9xuyn2oU5/9lB8go= +github.com/bluenviron/gomavlib/v2 v2.1.0/go.mod h1:omnSr00XvG6HVnDSM1vYgnvsVD/ihoPSV84cv/Km7rA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/main_test.go b/main_test.go index 3a17731..195bad5 100644 --- a/main_test.go +++ b/main_test.go @@ -61,7 +61,8 @@ func TestBroadcast(t *testing.T) { Z: 3.4, } - pub.WriteMessageAll(msg) + err = pub.WriteMessageAll(msg) + require.NoError(t, err) <-sub.Events() evt = <-sub.Events() @@ -124,17 +125,19 @@ func TestTarget(t *testing.T) { <-sub1.Events() <-sub2.Events() - sub1.WriteMessageAll(&common.MessageHeartbeat{ + err = sub1.WriteMessageAll(&common.MessageHeartbeat{ Type: common.MAV_TYPE_GCS, SystemStatus: 4, MavlinkVersion: 3, }) + require.NoError(t, err) - sub2.WriteMessageAll(&common.MessageHeartbeat{ + err = sub2.WriteMessageAll(&common.MessageHeartbeat{ Type: common.MAV_TYPE_GCS, SystemStatus: 4, MavlinkVersion: 3, }) + require.NoError(t, err) for i := 0; i < 2; i++ { evt := <-pub.Events() @@ -153,7 +156,8 @@ func TestTarget(t *testing.T) { Command: common.MAV_CMD_NAV_FOLLOW, } - pub.WriteMessageAll(msg) + err = pub.WriteMessageAll(msg) + require.NoError(t, err) <-sub1.Events() evt := <-sub1.Events() @@ -207,11 +211,12 @@ func TestTargetNotFound(t *testing.T) { <-pub.Events() <-sub.Events() - sub.WriteMessageAll(&common.MessageHeartbeat{ + err = sub.WriteMessageAll(&common.MessageHeartbeat{ Type: common.MAV_TYPE_GCS, SystemStatus: 4, MavlinkVersion: 3, }) + require.NoError(t, err) evt := <-pub.Events() eventFr, ok := evt.(*gomavlib.EventFrame) @@ -228,7 +233,8 @@ func TestTargetNotFound(t *testing.T) { Command: common.MAV_CMD_NAV_FOLLOW, } - pub.WriteMessageAll(msg) + err = pub.WriteMessageAll(msg) + require.NoError(t, err) evt = <-sub.Events() eventFr, ok = evt.(*gomavlib.EventFrame) diff --git a/message_handler.go b/message_handler.go index 5cc8a66..fcb5d7b 100644 --- a/message_handler.go +++ b/message_handler.go @@ -155,14 +155,14 @@ func (mh *messageHandler) onEventFrame(evt *gomavlib.EventFrame) { if key.channel == evt.Channel { log.Printf("Warning: channel %s attempted to send message to itself, discarding", key.channel) } else { - mh.node.WriteFrameTo(key.channel, evt.Frame) + mh.node.WriteFrameTo(key.channel, evt.Frame) //nolint:errcheck return } } } // otherwise, route message to every channel - mh.node.WriteFrameExcept(evt.Channel, evt.Frame) + mh.node.WriteFrameExcept(evt.Channel, evt.Frame) //nolint:errcheck } func (mh *messageHandler) onEventChannelClose(evt *gomavlib.EventChannelClose) {