aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorHans Verkuil <hansverk@cisco.com>2018-10-03 13:56:46 +0200
committerHans Verkuil <hansverk@cisco.com>2018-10-03 13:56:46 +0200
commit3598047c70e395d8ee0da5519996bc0126f18262 (patch)
tree1fed5eb0f320d679b5328561a4c4d707188caf45 /utils
parentb6469bbae150f006dbcebbcb0a0d528ba3af50db (diff)
cec-ctl: add --non-blocking option
With this option it is possible to transmit messages in non-blocking mode. Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/cec-ctl/cec-ctl.1.in3
-rw-r--r--utils/cec-ctl/cec-ctl.cpp9
2 files changed, 12 insertions, 0 deletions
diff --git a/utils/cec-ctl/cec-ctl.1.in b/utils/cec-ctl/cec-ctl.1.in
index d629077b..b9b1c39f 100644
--- a/utils/cec-ctl/cec-ctl.1.in
+++ b/utils/cec-ctl/cec-ctl.1.in
@@ -51,6 +51,9 @@ for the reply. This option applies to the messages following this option.
It acts as a toggle, so after you specify it a second time then the following
messages will wait for a reply again.
.TP
+\fB\-N\fR, \fB\-\-non\-blocking\fR
+Transmit messages in non-blocking mode.
+.TP
\fB\-t\fR, \fB\-\-to\fR \fI<la>\fR
Send the message to the given logical address (0-15).
.TP
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index ddce124b..9b289cb4 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -642,6 +642,7 @@ enum Option {
OptMonitor = 'm',
OptMonitorAll = 'M',
OptToggleNoReply = 'n',
+ OptNonBlocking = 'N',
OptOsdName = 'o',
OptPhysAddr = 'p',
OptPoll = 'P',
@@ -746,6 +747,7 @@ static struct option long_options[] = {
{ "store-pin", required_argument, 0, OptStorePin },
{ "analyze-pin", required_argument, 0, OptAnalyzePin },
{ "no-reply", no_argument, 0, OptToggleNoReply },
+ { "non-blocking", no_argument, 0, OptNonBlocking },
{ "logical-address", no_argument, 0, OptLogicalAddress },
{ "logical-addresses", no_argument, 0, OptLogicalAddresses },
{ "to", required_argument, 0, OptTo },
@@ -804,6 +806,7 @@ static void usage(void)
" -L, --logical-addresses Show all configured logical addresses\n"
" -C, --clear Clear all logical addresses\n"
" -n, --no-reply Toggle 'don't wait for a reply'\n"
+ " -N, --non-blocking Transmit messages in non-blocking mode\n"
" -t, --to <la> Send message to the given logical address\n"
" -f, --from <la> Send message from the given logical address\n"
" By default use the first assigned logical address\n"
@@ -2397,6 +2400,9 @@ int main(int argc, char **argv)
printf("\n");
}
+ if (options[OptNonBlocking])
+ fcntl(node.fd, F_SETFL, fcntl(node.fd, F_GETFL) | O_NONBLOCK);
+
for (msg_vec::iterator iter = msgs.begin(); iter != msgs.end(); ++iter) {
struct cec_msg msg = *iter;
@@ -2435,6 +2441,9 @@ int main(int argc, char **argv)
}
fflush(stdout);
+ if (options[OptNonBlocking])
+ fcntl(node.fd, F_SETFL, fcntl(node.fd, F_GETFL) & ~O_NONBLOCK);
+
skip_la:
if (options[OptMonitor] || options[OptMonitorAll] ||
options[OptMonitorPin] || options[OptStorePin])

Privacy Policy