ir-ctl: support raw format by default
PATCH 1/1 ir-ctl: support raw format by default
When "ir-ctl -r" outputs data it prints one line per space and pulse. This is not very space efficient and long protocols like rc-6 are unlikely to fit on the screen.
The new format is much more compact. A single IR message is printed on a single line. The pulse is prefixed with an optional + and a space is prefixed with -.
The rc-5 example from the man page becomes:
$ ir-ctl -r +889 -889 +1778 -1778 +889 -889 +889 -889 +889 -889 +1778 -889 +889 -889 +889 -889 +889 -889 +889 -889 +889 -1778 +889 # timeout 133889
The old behaviour can be resurrected with: ir-ctl -r --mode2
This commit also add support for sending the same format.
Signed-off-by Sean Young <[email protected]>
--- utils/common/keymap.c | 8 +- utils/ir-ctl/ir-ctl.1.in | 36 +++--- utils/ir-ctl/ir-ctl.c | 241 ++++++++++++++++++++++++++++++++------- 3 files changed, 228 insertions(+), 57 deletions(-)
utils/common/keymap.c +6 -2
@@ -272,19 +272,23 @@ static error_t parse_toml_raw_part(const char *fname, struct toml_array_t *raw,if (!traw) {fprintf (stderr,_ ("%s: missing raw value for entry %d\n" ), fname, ind); +free (keycode);return EINVAL ; }if (toml_rtos (traw, &raw_str)) {fprintf (stderr,_ ("%s: bad value `%s' for keycode\n" ), fname, traw); +free (keycode);return EINVAL ; } -if (parse_rawir_string (fname, raw_str, &re)) +if (parse_rawir_string (fname, raw_str, &re)) { +free (keycode);return EINVAL ; + } - re->keycode =strdup (keycode); + re->keycode = keycode; re->next = map->raw; map->raw = re; }
utils/ir-ctl/ir-ctl.1.in +23 -13
@@ -9,7 +9,7 @@ ir\-ctl \- a swiss\-knife tool to handle raw IR and to set lirc options [\fIOPTION\fR]... \fI\-\-features\fR .br .B ir\-ctl -[\fIOPTION\fR]... \fI\-\-send\fR [\fIpulse and space file to send\fR] +[\fIOPTION\fR]... \fI\-\-send\fR [\fIfile to send\fR] .br .B ir\-ctl [\fIOPTION\fR]... \fI\-\-scancode\fR [\fIprotocol and scancode to send\fR]
@@ -58,13 +58,16 @@ in\-order with a 125ms gap between them. The gap length can be modified with \fB\-\-gap\fR. .TP \fB-k\fR, \fB\-\-keymap\fR=\fIKEYMAP\fR -The rc keymap in toml format. The format is described in the rc_keymap(5) -man page. +The rc keymap file in toml format. The format is described in the rc_keymap(5) +man page. This file is used to select the \fBKEYCODE\fR from. .TP \fB\-1\fR, \fB\-\-oneshot\fR When receiving, stop receiving after the first message, i.e. after a space or timeout of more than 19ms is received. .TP +\fB\-\-mode2\fR +When receiving, output IR in mode2 format. One line per space or pulse. +.TP \fB\-w\fR, \fB\-\-wideband\fR Use the wideband receiver if available on the hardware. This is also known as learning mode. The measurements should be more precise and any
@@ -118,14 +121,17 @@ Verbose output; this prints the IR before sending. \fB\-V\fR, \fB\-\-version\fR print the v4l2\-utils version .PP -.SS Format of pulse and space file -When sending IR, the format of the file should be as follows. A comment -starts with #. The carrier frequency can be specified as: +.SS Format of file +When sending or receiving raw IR, two formats can be used. The first is +a list of integers representing pulse and space values. A pulse value can be +prefixed with + and a space with -, but this is optional. The rc-5 scancode +0x1e01 is encoded so: .PP - carrier 38000 ++889 -889 +1778 -1778 +889 -889 +889 -889 +889 -889 +1778 -889 +889 -889 +889 -889 +889 -889 +889 -889 +889 -1778 +889 .PP -The file should contain alternating lines with pulse and space, followed -by length in microseconds. The following is a rc-5 encoded message: +The other format mimics the mode2 tool. This produces one line per space +or pulse. For receiving it can selected by specifying \fB\-\-mode2\fR. Here is +the same message as above, now encoded in mode2: .PP carrier 36000 .br
@@ -175,9 +181,13 @@ by length in microseconds. The following is a rc-5 encoded message: .br pulse 840 .PP -Rather than specifying the raw IR, you can also specify the scancode and -protocol you want to send. This will also automatically set the correct -carrier. The above can be written as: +Note that in this format, the carrier can also be specified. This can only +by done with a separate \fB\-\-carrier=38000\fR command line option with +the first format. +.PP +Rather than specifying just the raw IR, in this format you can also specify +the scancode and protocol you want to send. This will also automatically set +the correct carrier. The above can be written as: .PP scancode rc5:0x1e01 .PP
@@ -244,7 +254,7 @@ To send the rc-5 hauppauge '1' scancode: .PP To send the rc-5 hauppauage '1' key from the hauppauge keymap: .br - \fBir\-ctl -k hauppauge.toml -K KEY_NUMERIC_0\fR + \fBir\-ctl -k hauppauge.toml -K KEY_NUMERIC_1\fR .SH BUGS Report bugs to \fBLinux Media Mailing List <[email protected]>\fR .SH COPYRIGHT
utils/ir-ctl/ir-ctl.c +199 -42
360 lines not on this page · raw message
Signature · 1 line
2.21.0