From c56818e40e72c069cf36f2da3e9b38944d0cf1b4 Mon Sep 17 00:00:00 2001 From: gswly <46489434+gswly@users.noreply.github.com> Date: Wed, 24 Apr 2019 12:12:10 +0200 Subject: [PATCH] add --print flag --- README.md | 6 +++--- main.go | 11 +++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cf8bf98..0d967f2 100644 --- a/README.md +++ b/README.md @@ -67,9 +67,9 @@ Flags: --help Show context-sensitive help (also try --help-long and --help-man). --version print mavp2p version - -q, --quiet suppress info messages during - execution - --print-errors print parse errors on screen + -q, --quiet suppress info messages + --print print routed frames + --print-errors print parse errors --hb-disable disable heartbeats --hb-version=1 set mavlink version of heartbeats --hb-systemid=125 set system id of heartbeats. it is diff --git a/main.go b/main.go index b0309a0..b8b15c3 100644 --- a/main.go +++ b/main.go @@ -89,8 +89,9 @@ func main() { version := kingpin.Flag("version", "print mavp2p version").Bool() - quiet := kingpin.Flag("quiet", "suppress info messages during execution").Short('q').Bool() - printErrors := kingpin.Flag("print-errors", "print parse errors on screen").Bool() + quiet := kingpin.Flag("quiet", "suppress info messages").Short('q').Bool() + print := kingpin.Flag("print", "print routed frames").Bool() + printErrors := kingpin.Flag("print-errors", "print parse errors").Bool() hbDisable := kingpin.Flag("hb-disable", "disable heartbeats").Bool() hbVersion := kingpin.Flag("hb-version", "set mavlink version of heartbeats").Default("1").Enum("1", "2") @@ -239,6 +240,12 @@ func main() { log.Printf("channel closed: %s", evt.Channel) case *gomavlib.EventFrame: + // print + if *print == true { + fmt.Printf("V=%T, %+v, ID=%d, %+v", evt.Frame, evt.Frame, + evt.Message().GetId(), evt.Message()) + } + // build remoteNode rnode := remoteNode{ Channel: evt.Channel,