From cf3b068179af193ab1eae3b917d15f6da5ec913a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 15 May 2017 16:58:50 +0200 Subject: [PATCH] mavlink: add 'verbose [on|off]' command --- src/modules/mavlink/mavlink_main.cpp | 12 +++++++++--- src/modules/mavlink/mavlink_main.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 9ff55251b9..8e5b674bf4 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -506,7 +506,7 @@ Mavlink::set_verbose(bool v) } int -Mavlink::set_verbose_all_instances() +Mavlink::set_verbose_all_instances(bool enabled) { Mavlink *inst = ::_mavlink_instances; @@ -514,7 +514,7 @@ Mavlink::set_verbose_all_instances() while (inst != nullptr) { - inst->set_verbose(true); + inst->set_verbose(enabled); /* move on */ inst = inst->next; @@ -2834,7 +2834,13 @@ int mavlink_main(int argc, char *argv[]) return Mavlink::get_status_all_instances(); } else if (!strcmp(argv[1], "verbose")) { - return Mavlink::set_verbose_all_instances(); + bool on = true; + + if (argc > 2 && !strcmp(argv[2], "off")) { + on = false; + } + + return Mavlink::set_verbose_all_instances(on); } else if (!strcmp(argv[1], "stream")) { return Mavlink::stream_command(argc, argv); diff --git a/src/modules/mavlink/mavlink_main.h b/src/modules/mavlink/mavlink_main.h index 111151f956..e245ce9c70 100644 --- a/src/modules/mavlink/mavlink_main.h +++ b/src/modules/mavlink/mavlink_main.h @@ -138,7 +138,7 @@ public: * This is primarily intended for analysis and * not intended for normal operation */ - static int set_verbose_all_instances(); + static int set_verbose_all_instances(bool enabled); static bool instance_exists(const char *device_name, Mavlink *self);