-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathmain.go
34 lines (30 loc) · 847 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"log"
"github.com/aler9/gomavlib"
"github.com/aler9/gomavlib/pkg/dialects/ardupilotmega"
)
func main() {
// create a node which
// - communicates with an UDP endpoint in client mode
// - understands ardupilotmega dialect
// - writes messages with given system id
node, err := gomavlib.NewNode(gomavlib.NodeConf{
Endpoints: []gomavlib.EndpointConf{
gomavlib.EndpointUDPClient{"1.2.3.4:5600"},
},
Dialect: ardupilotmega.Dialect,
OutVersion: gomavlib.V2, // change to V1 if you're unable to communicate with the target
OutSystemID: 10,
})
if err != nil {
panic(err)
}
defer node.Close()
// print every message we receive
for evt := range node.Events() {
if frm, ok := evt.(*gomavlib.EventFrame); ok {
log.Printf("received: id=%d, %+v\n", frm.Message().GetID(), frm.Message())
}
}
}