diff options
author | etobi <git@e-tobi.net> | 2013-09-03 09:48:38 +0200 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2013-09-03 09:48:38 +0200 |
commit | 6e40287e2f39a80fc72bd8d0fbc1a8334d688c2d (patch) | |
tree | 024bef311226653bdd1da4fa588becf5098bcff7 /test/set22k.c | |
download | linux-dvb-apps-6e40287e2f39a80fc72bd8d0fbc1a8334d688c2d.tar.gz |
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'test/set22k.c')
-rw-r--r-- | test/set22k.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/set22k.c b/test/set22k.c new file mode 100644 index 0000000..51ffa1c --- /dev/null +++ b/test/set22k.c @@ -0,0 +1,50 @@ +/* + * Test switching the 22kHz tone signal on and off on a SAT frontend. + * (Note: DiSEqC equipment ignores this after it has once seen a diseqc + * sequence; reload the driver or unplug/replug the SAT cable to reset.) + * + * usage: FRONTEND=/dev/dvb/adapterX/frontendX set22k {on|off} + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include <linux/dvb/frontend.h> + + +int main (int argc, char **argv) +{ + char *fedev = "/dev/dvb/adapter0/frontend0"; + int fd, r; + + if (argc != 2 || (strcmp(argv[1], "on") && strcmp(argv[1], "off"))) { + fprintf (stderr, "usage: %s <on|off>\n", argv[0]); + return 1; + } + if (getenv("FRONTEND")) + fedev = getenv("FRONTEND"); + printf("set22k: using '%s'\n", fedev); + + if ((fd = open (fedev, O_RDWR)) < 0) { + perror ("open"); + return 1; + } + + if (strcmp(argv[1], "on") == 0) + r = ioctl (fd, FE_SET_TONE, SEC_TONE_ON); + else + r = ioctl (fd, FE_SET_TONE, SEC_TONE_OFF); + if (r == -1) + perror("ioctl FE_SET_TONE"); + + close (fd); + + return 0; +} + |