aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--utils/ir-ctl/ir-ctl.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
index 6013b472..bc58cee0 100644
--- a/utils/ir-ctl/ir-ctl.c
+++ b/utils/ir-ctl/ir-ctl.c
@@ -20,6 +20,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
+#include <errno.h>
#include <fcntl.h>
#include <argp.h>
#include <sysexits.h>
@@ -733,12 +734,18 @@ static void lirc_features(struct arguments *args, int fd, unsigned features)
static int lirc_send(struct arguments *args, int fd, unsigned features, struct file *f)
{
const char *dev = args->device;
+ int mode = LIRC_MODE_PULSE;
if (!(features & LIRC_CAN_SEND_PULSE)) {
- fprintf(stderr, _("%s: device cannot send\n"), dev);
+ fprintf(stderr, _("%s: device cannot send raw ir\n"), dev);
return EX_UNAVAILABLE;
}
+ if (ioctl(fd, LIRC_SET_SEND_MODE, &mode)) {
+ fprintf(stderr, _("%s: failed to set send mode: %m\n"), dev);
+ return EX_IOERR;
+ }
+
if (args->carrier && f->carrier)
fprintf(stderr, _("warning: %s: carrier specified but overwritten on command line\n"), f->fname);
else if (f->carrier && args->carrier == 0)
@@ -775,6 +782,18 @@ int lirc_record(struct arguments *args, int fd, unsigned features)
char *dev = args->device;
FILE *out = stdout;
int rc = EX_IOERR;
+ int mode = LIRC_MODE_MODE2;
+
+ if (!(features & LIRC_CAN_REC_MODE2)) {
+ fprintf(stderr, _("%s: device cannot record raw ir\n"), dev);
+ return EX_UNAVAILABLE;
+ }
+
+ // kernel v4.8 and v4.9 return ENOTTY
+ if (ioctl(fd, LIRC_SET_REC_MODE, &mode) && errno != ENOTTY) {
+ fprintf(stderr, _("%s: failed to set record mode: %m\n"), dev);
+ return EX_IOERR;
+ }
if (args->savetofile) {
out = fopen(args->savetofile, "w");

Privacy Policy