setvoltage.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include <stdlib.h>
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <unistd.h>
  13. #include <sys/ioctl.h>
  14. #include <sys/types.h>
  15. #include <sys/stat.h>
  16. #include <fcntl.h>
  17. #include <linux/dvb/frontend.h>
  18. int main (int argc, char **argv)
  19. {
  20. char *fedev = "/dev/dvb/adapter0/frontend0";
  21. int fd, r;
  22. if (argc != 2 || (strcmp(argv[1], "13") && strcmp(argv[1], "18"))) {
  23. fprintf (stderr, "usage: %s <13|18>\n" USAGE, argv[0]);
  24. return -1;
  25. }
  26. if (getenv("FRONTEND"))
  27. fedev = getenv("FRONTEND");
  28. printf("setvoltage: using '%s'\n", fedev);
  29. if ((fd = open (fedev, O_RDWR)) < 0)
  30. perror ("open");
  31. if (strcmp(argv[1], "13") == 0)
  32. r = ioctl (fd, FE_SET_VOLTAGE, SEC_VOLTAGE_13);
  33. else
  34. r = ioctl (fd, FE_SET_VOLTAGE, SEC_VOLTAGE_18);
  35. if (r == -1)
  36. perror ("ioctl FE_SET_VOLTAGE");
  37. close (fd);
  38. return 0;
  39. }