From 739b0360fbe29997aa36b1b2642a0835bd7d5129 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Wed, 4 Oct 2023 16:44:57 +0200 Subject: [PATCH] change default component ID to 191; add --hb-componentid (#46) --- README.md | 77 +++++++++++++++++++++++++------------------------------ main.go | 8 +++--- 2 files changed, 40 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index e2327e3..084fd36 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Features: * [Usage](#usage) * [Comparison with similar software](#comparison-with-similar-software) * [Full command-line usage](#full-command-line-usage) -* [Standards](#standards) +* [Specifications](#specifications) * [Links](#links) ## Installation @@ -128,55 +128,48 @@ _mavp2p_ vs _mavlink-router_ ## Full command-line usage ``` -usage: mavp2p [] [...] +Usage: mavp2p [ ...] mavp2p v0.0.0 -Link together Mavlink endpoints. +Arguments: + [ ...] Space-separated list of endpoints. At least one endpoint is required. Possible endpoints types are: -Flags: - --help Show context-sensitive help (also try - --help-long and --help-man). - --version print version - -q, --quiet suppress info messages - --print print routed frames - --print-errors print parse errors singularly, instead of - printing only their quantity every 5 seconds - --hb-disable disable heartbeats - --hb-version=1 set mavlink version of heartbeats - --hb-systemid=125 set system id of heartbeats. it is - recommended to set a different system - id for each router in the network - --hb-period=5 set period of heartbeats - --streamreq-disable do not request streams to Ardupilot - devices, that need an explicit request - in order to emit telemetry streams. - this task is usually delegated to the - router, in order to avoid conflicts when - multiple ground stations are active - --streamreq-frequency=4 set the stream frequency to request - -Args: - [] Space-separated list of endpoints. At least one - endpoint is required. Possible endpoints kinds are: - - udps:listen_ip:port (udp, server mode) - - udpc:dest_ip:port (udp, client mode) - - udpb:broadcast_ip:port (udp, broadcast mode) - - tcps:listen_ip:port (tcp, server mode) - - tcpc:dest_ip:port (tcp, client mode) - - serial:port:baudrate (serial) + udpc:dest_ip:port (udp, client mode) + + udpb:broadcast_ip:port (udp, broadcast mode) + + tcps:listen_ip:port (tcp, server mode) + + tcpc:dest_ip:port (tcp, client mode) + serial:port:baudrate (serial) + + udps:listen_ip:port (udp, server mode) + +Flags: + -h, --help Show context-sensitive help. + --version print version. + -q, --quiet suppress info messages. + --print print routed frames. + --print-errors print parse errors singularly, instead of printing only their quantity every 5 seconds. + --read-timeout=10s timeout of read operations. + --write-timeout=10s timeout of write operations. + --idle-timeout=60s disconnect idle connections after a timeout. + --hb-disable disable heartbeats. + --hb-version=1 set mavlink version of heartbeats. + --hb-systemid=125 set system ID of heartbeats. it is recommended to set a different system id for each router in the network. + --hb-componentid=191 set component ID of heartbeats. + --hb-period=5 set period of heartbeats. + --streamreq-disable do not request streams to Ardupilot devices, that need an explicit request + in order to emit telemetry streams. this task is usually delegated to the router, + in order to avoid conflicts when multiple ground stations are active. + --streamreq-frequency=4 set the stream frequency to request. ``` -## Standards +## Specifications -* [Mavlink standards](https://github.com/bluenviron/gomavlib#standards) +* [Mavlink specifications](https://github.com/bluenviron/gomavlib#specifications) ## Links diff --git a/main.go b/main.go index 1c14e4f..9ea5178 100644 --- a/main.go +++ b/main.go @@ -148,8 +148,9 @@ var cli struct { WriteTimeout time.Duration `help:"timeout of write operations." default:"10s"` IdleTimeout time.Duration `help:"disconnect idle connections after a timeout." default:"60s"` HbDisable bool `help:"disable heartbeats."` - HbVersion string `enum:"1,2" help:"set mavlink version of heartbeats." default:"1"` + HbVersion int `enum:"1,2" help:"set mavlink version of heartbeats." default:"1"` HbSystemid int `default:"125"` + HbComponentid int `help:"set component ID of heartbeats." default:"191"` HbPeriod int `help:"set period of heartbeats." default:"5"` StreamreqDisable bool StreamreqFrequency int `help:"set the stream frequency to request." default:"4"` @@ -175,7 +176,7 @@ func newProgram(args []string) (*program, error) { return "print parse errors singularly, instead of printing only their quantity every 5 seconds." case "hb-systemid": - return "set system id of heartbeats. it is recommended to set a different system id for each router in the network." + return "set system ID of heartbeats. it is recommended to set a different system id for each router in the network." case "streamreq-disable": return "do not request streams to Ardupilot devices," + @@ -231,12 +232,13 @@ func newProgram(args []string) (*program, error) { Endpoints: endpointConfs, Dialect: generateDialect(cli.HbDisable, cli.StreamreqDisable), OutVersion: func() gomavlib.Version { - if cli.HbVersion == "2" { + if cli.HbVersion == 2 { return gomavlib.V2 } return gomavlib.V1 }(), OutSystemID: byte(cli.HbSystemid), + OutComponentID: byte(cli.HbComponentid), HeartbeatDisable: cli.HbDisable, HeartbeatPeriod: (time.Duration(cli.HbPeriod) * time.Second), StreamRequestEnable: !cli.StreamreqDisable,