1 #define USAGE \
2 "\n" \
3 "\nTest switching the voltage signal high and low on a SAT frontend." \
4 "\n(Note: DiSEqC equipment ignores this after it has once seen a diseqc" \
5 "\n sequence; reload the driver or unplug/replug the SAT cable to reset.)" \
6 "\n" \
7 "\nusage: FRONTEND=/dev/dvb/adapterX/frontendX setvoltage {13|18}" \
8 "\n"
9 
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
13 #include <unistd.h>
14 #include <sys/ioctl.h>
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include <fcntl.h>
18 #include <linux/dvb/frontend.h>
19 
20 
main(int argc,char ** argv)21 int main (int argc, char **argv)
22 {
23    char *fedev = "/dev/dvb/adapter0/frontend0";
24    int fd, r;
25 
26    if (argc != 2 || (strcmp(argv[1], "13") && strcmp(argv[1], "18"))) {
27       fprintf (stderr, "usage: %s <13|18>\n" USAGE, argv[0]);
28       return -1;
29    }
30    if (getenv("FRONTEND"))
31 	   fedev = getenv("FRONTEND");
32    printf("setvoltage: using '%s'\n", fedev);
33 
34    if ((fd = open (fedev, O_RDWR)) < 0)
35       perror ("open");
36 
37    if (strcmp(argv[1], "13") == 0)
38       r = ioctl (fd, FE_SET_VOLTAGE, SEC_VOLTAGE_13);
39    else
40       r = ioctl (fd, FE_SET_VOLTAGE, SEC_VOLTAGE_18);
41    if (r == -1)
42 	   perror ("ioctl FE_SET_VOLTAGE");
43 
44    close (fd);
45 
46    return 0;
47 }
48