// SPDX-License-Identifier: GPL-2.0 // test ir decoder // // Copyright (C) 2018 Sean Young <sean@mess.org>
// When sending LIRC_MODE_SCANCODE, the IR will be encoded. rc-loopback // will send this IR to the receiver side, where we try to read the decoded // IR. Decoding happens in a separate kernel thread, so we will need to // wait until that is scheduled, hence we use poll to check for read // readiness.
/* * Support ancient lirc.h which does not have these values. Can be removed * once RHEL 8 is no longer a relevant testing platform.
*/ #if RC_PROTO_MAX < 26 #define RC_PROTO_RCMM12 24 #define RC_PROTO_RCMM24 25 #define RC_PROTO_RCMM32 26 #endif
int main(int argc, char **argv)
{ unsignedint mode; char buf[100]; int rlircfd, wlircfd, protocolfd, i, n;
srand(time(NULL));
if (argc != 3)
ksft_exit_fail_msg("Usage: %s \n",
argv[0]);
rlircfd = lirc_open(argv[2]);
mode = LIRC_MODE_SCANCODE; if (ioctl(rlircfd, LIRC_SET_REC_MODE, &mode))
ksft_exit_fail_msg("failed to set scancode rec mode %s: %m\n",
argv[2]);
wlircfd = lirc_open(argv[1]); if (ioctl(wlircfd, LIRC_SET_SEND_MODE, &mode))
ksft_exit_fail_msg("failed to set scancode send mode %s: %m\n",
argv[1]);
snprintf(buf, sizeof(buf), "/sys/class/rc/%s/protocols", argv[2]);
protocolfd = open(buf, O_WRONLY); if (protocolfd == -1)
ksft_exit_fail_msg("failed to open %s: %m\n", buf);
printf("Sending IR on %s and receiving IR on %s.\n", argv[1], argv[2]);
for (i = 0; i < ARRAY_SIZE(protocols); i++) { if (write(protocolfd, protocols[i].decoder,
strlen(protocols[i].decoder)) == -1)
ksft_exit_fail_msg("failed to set write decoder\n");
printf("Testing protocol %s for decoder %s (%d/%d)...\n",
protocols[i].name, protocols[i].decoder,
i + 1, (int)ARRAY_SIZE(protocols));
for (n = 0; n < TEST_SCANCODES; n++) { unsignedint scancode = rand() & protocols[i].mask; unsignedint rc_proto = protocols[i].proto;
if (rc_proto == RC_PROTO_RC6_MCE)
scancode |= 0x800f0000;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.