From d158bdde091363004c47c5272ea0e1d7a72f95d0 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 10 Jan 2020 05:08:51 +0000 Subject: [PATCH 1/3] Add the ability to set a universe to blackout instead via ola_set_dmx Currently untested (cherry picked from commit 54ac1fb6ec9376944b0aec0a8c12f0d1a74243a0) --- examples/ola-client.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/examples/ola-client.cpp b/examples/ola-client.cpp index f6eeab53c9..aa001d2d2e 100644 --- a/examples/ola-client.cpp +++ b/examples/ola-client.cpp @@ -84,6 +84,7 @@ typedef struct { string cmd; // argv[0] string uni_name; // universe name string dmx; // DMX string + bool blackout; ola::port_priority_mode priority_mode; // port priority mode uint8_t priority_value; // port priority value bool list_plugin_ids; @@ -304,6 +305,7 @@ void InitOptions(options *opts) { opts->port_direction = ola::client::OUTPUT_PORT; opts->device_id = INVALID_VALUE; opts->merge_mode = OlaUniverse::MERGE_HTP; + opts->blackout = false; opts->priority_mode = ola::PRIORITY_MODE_INHERIT; opts->priority_value = 0; } @@ -358,6 +360,7 @@ void ParseOptions(int argc, char *argv[], options *opts) { static struct option long_options[] = { {"dmx", required_argument, 0, 'd'}, + {"blackout", no_argument, 0, 'b'}, {"help", no_argument, 0, 'h'}, {"ltp", no_argument, 0, 'l'}, {"name", required_argument, 0, 'n'}, @@ -373,7 +376,7 @@ void ParseOptions(int argc, char *argv[], options *opts) { int option_index = 0; while (1) { - c = getopt_long(argc, argv, "ld:n:u:p:s:hv", long_options, &option_index); + c = getopt_long(argc, argv, "ld:bn:u:p:s:hv", long_options, &option_index); if (c == -1) break; @@ -384,6 +387,9 @@ void ParseOptions(int argc, char *argv[], options *opts) { case 'd': opts->dmx = optarg; break; + case 'b': + opts->blackout = true; + break; case 'h': opts->help = true; break; @@ -656,7 +662,8 @@ void DisplayUniverseMergeHelp(const options &opts) { * Help message for set dmx */ void DisplaySetDmxHelp(const options &opts) { - cout << "Usage: " << opts.cmd << " --universe --dmx \n" + cout << "Usage: " << opts.cmd << " --universe [ --dmx ] " + "[ --blackout ]\n" "\n" "Sets the DMX values for a universe.\n" "\n" @@ -665,6 +672,7 @@ void DisplaySetDmxHelp(const options &opts) { " -d, --dmx Comma separated DMX values, e.g. " "0,255,128 sets first channel to 0, second channel to 255" " and third channel to 128.\n" + " -b, --blackout Send a universe to blackout instead.\n" << endl; } @@ -857,9 +865,16 @@ int SendDmx(OlaClientWrapper *wrapper, const options &opts) { SelectServer *ss = wrapper->GetSelectServer(); OlaClient *client = wrapper->GetClient(); ola::DmxBuffer buffer; - bool status = buffer.SetFromString(opts.dmx); + bool status = false; + if (opts.blackout) { + status = buffer.Blackout(); + } else { + status = buffer.SetFromString(opts.dmx); + } - if (opts.uni < 0 || !status || buffer.Size() == 0) { + // A dmx string and blackout are mutually exclusive + if (opts.uni < 0 || !status || (opts.blackout && !opts.dmx.empty) || + buffer.Size() == 0) { DisplaySetDmxHelp(opts); exit(1); } From 1d1c91a8fd7ffaa0f9bcd34e1991d2d213c22370 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 10 Jan 2020 05:13:46 +0000 Subject: [PATCH 2/3] Update the man page (cherry picked from commit bdb844efb97c5961223222014dd4bf76f111123b) --- man/ola_set_dmx.1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/man/ola_set_dmx.1 b/man/ola_set_dmx.1 index 0de61b95f7..89f95379bb 100644 --- a/man/ola_set_dmx.1 +++ b/man/ola_set_dmx.1 @@ -4,7 +4,7 @@ ola_set_dmx \- Sets the DMX values for a universe. .SH SYNOPSIS .B ola_set_dmx -\fI--universe --dmx \fR +\fI--universe [ --dmx ] [ --blackout ]\fR .SH DESCRIPTION Sets the DMX values for a universe. .TP @@ -15,3 +15,7 @@ Display this help message and exit. .TP \fB\-d\fR, \fB\-\-dmx\fR Comma separated DMX values, e.g. 0,255,128 sets first channel to 0, second channel to 255 and third channel to 128. +.HP +\fB\-b\fR, \fB\-\-blackout\fR +Send a universe to blackout instead. +.TP From e22dbcb0fa5188aad0e8837886c3a7dbf4af6817 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Thu, 7 Sep 2023 16:00:58 +0100 Subject: [PATCH 3/3] Fix the compilation --- examples/ola-client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ola-client.cpp b/examples/ola-client.cpp index aa001d2d2e..c639889efd 100644 --- a/examples/ola-client.cpp +++ b/examples/ola-client.cpp @@ -873,7 +873,7 @@ int SendDmx(OlaClientWrapper *wrapper, const options &opts) { } // A dmx string and blackout are mutually exclusive - if (opts.uni < 0 || !status || (opts.blackout && !opts.dmx.empty) || + if (opts.uni < 0 || !status || (opts.blackout && !opts.dmx.empty()) || buffer.Size() == 0) { DisplaySetDmxHelp(opts); exit(1);