From patchwork Tue Sep 26 20:23:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 9972707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 030086037E for ; Tue, 26 Sep 2017 20:24:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE61428F89 for ; Tue, 26 Sep 2017 20:24:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E395A28F9B; Tue, 26 Sep 2017 20:24:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 277B728F9F for ; Tue, 26 Sep 2017 20:24:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970462AbdIZUXz (ORCPT ); Tue, 26 Sep 2017 16:23:55 -0400 Received: from gofer.mess.org ([88.97.38.141]:52659 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967680AbdIZUXy (ORCPT ); Tue, 26 Sep 2017 16:23:54 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id D403B605E1; Tue, 26 Sep 2017 21:23:52 +0100 (BST) From: Sean Young To: linux-media@vger.kernel.org Subject: [PATCH 1/5] ir-ctl: a pulse space file cannot contain scancode and raw IR Date: Tue, 26 Sep 2017 21:23:48 +0100 Message-Id: <20170926202352.10276-1-sean@mess.org> X-Mailer: git-send-email 2.11.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This simplifies dealing with kernel encoders and raw IR, and does not make much sense anyway. Signed-off-by: Sean Young --- utils/ir-ctl/ir-ctl.1.in | 7 ++----- utils/ir-ctl/ir-ctl.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/utils/ir-ctl/ir-ctl.1.in b/utils/ir-ctl/ir-ctl.1.in index 05550fb1..401521da 100644 --- a/utils/ir-ctl/ir-ctl.1.in +++ b/utils/ir-ctl/ir-ctl.1.in @@ -168,11 +168,8 @@ carrier. The above can be written as: .PP scancode rc5:0x1e01 .PP -Do not specify scancodes with different protocols in one file, as the -carrier might differ and the transmitter cannot send this. Multiple -scancodes can be specified in one file but ensure that the rules for the -protocol are met by inserting an appropriate space between them. Also, -there are limits to what lirc devices can send in one go. +If you specify a scancode in a pulse space file, no other pulse, space or +even carrier may be specified. .PP .SS Supported Protocols A scancode with protocol can be specified on the command line or in the diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c index d3cce6a6..7dcdd983 100644 --- a/utils/ir-ctl/ir-ctl.c +++ b/utils/ir-ctl/ir-ctl.c @@ -187,7 +187,7 @@ static unsigned parse_emitters(char *p) static struct file *read_file(const char *fname) { - bool expect_pulse = true; + bool expect_pulse = true, seen_scancode = false; int lineno = 0, lastspace = 0; char line[1024]; int len = 0; @@ -229,8 +229,8 @@ static struct file *read_file(const char *fname) unsigned scancode, carrier; char *scancodestr; - if (!expect_pulse) { - fprintf(stderr, _("error: %s:%d: space must precede scancode\n"), fname, lineno); + if (len) { + fprintf(stderr, _("error: %s:%d: scancode must be appear in file by itself\n"), fname, lineno); return NULL; } @@ -269,6 +269,7 @@ static struct file *read_file(const char *fname) f->carrier = carrier; len += protocol_encode(proto, scancode, f->buf); + seen_scancode = true; continue; } @@ -284,6 +285,11 @@ static struct file *read_file(const char *fname) continue; } + if (seen_scancode) { + fprintf(stderr, _("error: %s:%d: scancode must be appear in file by itself\n"), fname, lineno); + return NULL; + } + if (strcmp(keyword, "space") == 0) { if (expect_pulse) { if (len == 0) {