sendburst.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #define USAGE \
  2. "\n" \
  3. "\nTest sending the burst mini command A/B on a SAT frontend." \
  4. "\n" \
  5. "\nusage: FRONTEND=/dev/dvb/adapterX/frontendX sendburst {a|b}" \
  6. "\n"
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <unistd.h>
  11. #include <sys/ioctl.h>
  12. #include <sys/types.h>
  13. #include <sys/stat.h>
  14. #include <fcntl.h>
  15. #include <linux/dvb/frontend.h>
  16. int main (int argc, char **argv)
  17. {
  18. char *fedev = "/dev/dvb/adapter0/frontend0";
  19. int fd, r;
  20. if (argc != 2 || (strcmp(argv[1], "a") && strcmp(argv[1], "b"))) {
  21. fprintf (stderr, "usage: %s <a|b>\n" USAGE, argv[0]);
  22. return 1;
  23. }
  24. if (getenv("FRONTEND"))
  25. fedev = getenv("FRONTEND");
  26. printf("set22k: using '%s'\n", fedev);
  27. if ((fd = open (fedev, O_RDWR)) < 0) {
  28. perror ("open");
  29. return 1;
  30. }
  31. ioctl (fd, FE_SET_TONE, SEC_TONE_OFF);
  32. usleep (30000); /* 30ms according to DiSEqC spec */
  33. if (strcmp(argv[1], "a") == 0)
  34. r = ioctl (fd, FE_DISEQC_SEND_BURST, SEC_MINI_A);
  35. else
  36. r = ioctl (fd, FE_DISEQC_SEND_BURST, SEC_MINI_B);
  37. if (r == -1)
  38. perror("ioctl FE_SET_TONE");
  39. close (fd);
  40. return 0;
  41. }