From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org
Cc: Matthias Reichl <hias@horus.com>
Subject: [PATCH 2/2] ir-ctl: specify the gap between scancodes or files
Date: Wed, 29 Nov 2017 20:17:32 +0000 [thread overview]
Message-ID: <20171129201732.23797-2-sean@mess.org> (raw)
In-Reply-To: <20171129201732.23797-1-sean@mess.org>
When sending multiple scancodes, or pulse space files, by default there
is 125ms gap between them. Allow this to be specified.
Signed-off-by: Sean Young <sean@mess.org>
---
utils/ir-ctl/ir-ctl.1.in | 5 +++++
utils/ir-ctl/ir-ctl.c | 18 +++++++++++++-----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/utils/ir-ctl/ir-ctl.1.in b/utils/ir-ctl/ir-ctl.1.in
index 05550fb1..89aa281f 100644
--- a/utils/ir-ctl/ir-ctl.1.in
+++ b/utils/ir-ctl/ir-ctl.1.in
@@ -93,6 +93,11 @@ Comma separated list of emitters to use for sending. The first emitter is
number 1. Some devices only support enabling one emitter (the winbond-cir
driver).
.TP
+\fB\-g\fR, \fB\-\-gap\fR=\fIGAP\fR
+Set the gap time between scancodes, or the gap between files when
+multiple are specified on the command line. By default this is 125000
+microseconds.
+.TP
\fB\-?\fR, \fB\-\-help\fR
Prints the help message
.TP
diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
index 8538ec5d..6fb05b1a 100644
--- a/utils/ir-ctl/ir-ctl.c
+++ b/utils/ir-ctl/ir-ctl.c
@@ -82,6 +82,7 @@ struct arguments {
int wideband;
unsigned carrier_low, carrier_high;
unsigned timeout;
+ unsigned gap;
int carrier_reports;
int timeout_reports;
unsigned carrier;
@@ -111,6 +112,7 @@ static const struct argp_option options[] = {
{ "carrier", 'c', N_("CARRIER"), 0, N_("set send carrier") },
{ "duty-cycle", 'D', N_("DUTY"), 0, N_("set duty cycle") },
{ "emitters", 'e', N_("EMITTERS"), 0, N_("set send emitters") },
+ { "gap", 'g', N_("GAP"), 0, N_("set gap between files or scancodes") },
{ }
};
@@ -130,6 +132,7 @@ static const char doc[] = N_(
" CARRIER - the carrier frequency to use for sending\n"
" DUTY - the duty cycle to use for sending\n"
" EMITTERS - comma separated list of emitters to use for sending, e.g. 1,2\n"
+ " GAP - gap between pulse and files or scancodes in microseconds\n"
" RANGE - set range of accepted carrier frequencies, e.g. 20000-40000\n"
" TIMEOUT - set length of space before recording stops in microseconds\n"
" SCANCODE - protocol:scancode, e.g. nec:0xa814\n\n"
@@ -185,7 +188,7 @@ static unsigned parse_emitters(char *p)
return emit;
}
-static struct file *read_file(const char *fname)
+static struct file *read_file(struct arguments *args, const char *fname)
{
bool expect_pulse = true;
int lineno = 0, lastspace = 0;
@@ -230,7 +233,7 @@ static struct file *read_file(const char *fname)
char *scancodestr;
if (!expect_pulse) {
- f->buf[len++] = IR_DEFAULT_TIMEOUT;
+ f->buf[len++] = args->gap;
expect_pulse = true;
}
@@ -486,6 +489,11 @@ static error_t parse_opt(int k, char *arg, struct argp_state *state)
if (arguments->emitters == 0)
argp_error(state, _("cannot parse emitters `%s'"), arg);
break;
+ case 'g':
+ arguments->gap = strtoint(arg, "");
+ if (arguments->gap == 0)
+ argp_error(state, _("cannot parse gap `%s'"), arg);
+ break;
case 'D':
arguments->duty = strtoint(arg, "%");
if (arguments->duty == 0 || arguments->duty >= 100)
@@ -494,7 +502,7 @@ static error_t parse_opt(int k, char *arg, struct argp_state *state)
case 's':
if (arguments->record || arguments->features)
argp_error(state, _("send can not be combined with record or features option"));
- s = read_file(arg);
+ s = read_file(arguments, arg);
if (s == NULL)
exit(EX_DATAERR);
@@ -884,7 +892,7 @@ err:
int main(int argc, char *argv[])
{
- struct arguments args = {};
+ struct arguments args = { .gap = IR_DEFAULT_TIMEOUT };
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
@@ -912,7 +920,7 @@ int main(int argc, char *argv[])
while (s) {
struct file *next = s->next;
if (s != args.send)
- usleep(IR_DEFAULT_TIMEOUT);
+ usleep(args.gap);
rc = lirc_send(&args, fd, features, s);
if (rc) {
--
2.14.3
next prev parent reply other threads:[~2017-11-29 20:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 14:44 [BUG] ir-ctl: error sending file with multiple scancodes Matthias Reichl
2017-11-29 20:05 ` Sean Young
2017-11-29 20:17 ` [PATCH 1/2] ir-ctl: fix multiple scancodes in one file Sean Young
2017-11-29 20:17 ` Sean Young [this message]
2017-11-30 15:34 ` [BUG] ir-ctl: error sending file with multiple scancodes Matthias Reichl
2017-11-30 22:27 ` Sean Young
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171129201732.23797-2-sean@mess.org \
--to=sean@mess.org \
--cc=hias@horus.com \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).