github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/examples/dialect-no/main.go (about) 1 package main 2 3 import ( 4 "log" 5 6 "github.com/bluenviron/gomavlib/v2" 7 ) 8 9 // this example shows how to: 10 // 1) create a node with no dialect, that doesn't attempt to decode messages 11 // 2) print incoming messages 12 13 func main() { 14 // create a node with no dialect, that doesn't attempt to decode messages 15 node, err := gomavlib.NewNode(gomavlib.NodeConf{ 16 Endpoints: []gomavlib.EndpointConf{ 17 gomavlib.EndpointSerial{ 18 Device: "/dev/ttyUSB0", 19 Baud: 57600, 20 }, 21 }, 22 Dialect: nil, 23 OutVersion: gomavlib.V2, // change to V1 if you're unable to communicate with the target 24 OutSystemID: 10, 25 }) 26 if err != nil { 27 panic(err) 28 } 29 defer node.Close() 30 31 // print incoming messages 32 for evt := range node.Events() { 33 if frm, ok := evt.(*gomavlib.EventFrame); ok { 34 log.Printf("received: id=%d, %+v\n", frm.Message().GetID(), frm.Message()) 35 } 36 } 37 }