Skip to content

Commit

Permalink
update gomavlib (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Aug 18, 2023
1 parent 59b57bf commit 204a63a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
18 changes: 12 additions & 6 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 204a63a

Please sign in to comment.