Advertisement
svenhoefer

Untitled

Nov 13th, 2017
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.80 KB | None | 0 0
  1. diff --git a/src/neutrino.cpp b/src/neutrino.cpp
  2. index f350f12..f747449 100644
  3. --- a/src/neutrino.cpp
  4. +++ b/src/neutrino.cpp
  5. @@ -2320,20 +2320,23 @@ void wake_up(bool &wakeup)
  6.         close(fd);
  7.     }
  8.  #endif
  9. -#if HAVE_ARM_HARDWARE
  10. -   FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "r");
  11. -   if (f)
  12. +   /* prioritize proc filesystem */
  13. +   if (access("/proc/stb/fp/was_timer_wakeup", F_OK) == 0)
  14.     {
  15. -       unsigned int tmp;
  16. -       if (fscanf(f, "%u", &tmp) != 1)
  17. -           printf("[neutrino] read /proc/stb/fp/was_timer_wakeup failed: %m\n");
  18. -       else
  19. -           wakeup = (tmp > 0);
  20. -       fclose(f);
  21. +       FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "r");
  22. +       if (f)
  23. +       {
  24. +           unsigned int tmp;
  25. +           if (fscanf(f, "%u", &tmp) != 1)
  26. +               printf("[neutrino] read /proc/stb/fp/was_timer_wakeup failed: %m\n");
  27. +           else
  28. +               wakeup = (tmp > 0);
  29. +           fclose(f);
  30. +       }
  31.     }
  32. -#endif // HAVE_ARM_HARDWARE
  33.     /* not platform specific - this is created by the init process */
  34. -   if (access("/tmp/.timer_wakeup", F_OK) == 0) {
  35. +   else if (access("/tmp/.timer_wakeup", F_OK) == 0)
  36. +   {
  37.         wakeup = 1;
  38.         unlink("/tmp/.timer_wakeup");
  39.     }
  40. @@ -4188,33 +4191,38 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
  41.  #endif
  42.     if (timer_minutes || leds)
  43.     {
  44. -#if HAVE_ARM_HARDWARE
  45. -       FILE *f = fopen("/proc/stb/fp/wakeup_time","w");
  46. -       if (f)
  47. +       /* prioritize proc filesystem */
  48. +       if (access("/proc/stb/fp/was_timer_wakeup", F_OK) == 0)
  49.         {
  50. -           time_t t = timer_minutes * 60;
  51. -           struct tm *tm = localtime(&t);
  52. -           char date[30];
  53. -           strftime(date, sizeof(date), "%c", tm);
  54. -           fprintf(stderr, "timer_wakeup: %s (%ld)\n", date, timer_minutes * 60);
  55. -           fprintf(f, "%ld\n", timer_minutes * 60);
  56. -           fclose(f);
  57. +           FILE *f = fopen("/proc/stb/fp/wakeup_time","w");
  58. +           if (f)
  59. +           {
  60. +               time_t t = timer_minutes * 60;
  61. +               struct tm *tm = localtime(&t);
  62. +               char date[30];
  63. +               strftime(date, sizeof(date), "%c", tm);
  64. +               fprintf(stderr, "timer_wakeup: %s (%ld)\n", date, timer_minutes * 60);
  65. +               fprintf(f, "%ld\n", timer_minutes * 60);
  66. +               fclose(f);
  67. +           }
  68. +           else
  69. +               perror("fopen /proc/stb/fp/wakeup_time");
  70.         }
  71. +       /* not platform specific */
  72.         else
  73. -           perror("fopen /proc/stb/fp/wakeup_time");
  74. -#else
  75. -       FILE *f = fopen("/tmp/.timer", "w");
  76. -       if (f)
  77.         {
  78. -           fprintf(stderr, "timer_wakeup: %ld\n", timer_minutes * 60);
  79. -           fprintf(f, "%ld\n", timer_minutes * 60);
  80. -           fprintf(f, "%d\n", leds);
  81. -           fprintf(f, "%d\n", bright);
  82. -           fclose(f);
  83. +           FILE *f = fopen("/tmp/.timer", "w");
  84. +           if (f)
  85. +           {
  86. +               fprintf(stderr, "timer_wakeup: %ld\n", timer_minutes * 60);
  87. +               fprintf(f, "%ld\n", timer_minutes * 60);
  88. +               fprintf(f, "%d\n", leds);
  89. +               fprintf(f, "%d\n", bright);
  90. +               fclose(f);
  91. +           }
  92. +           else
  93. +               perror("fopen /tmp/.timer");
  94.         }
  95. -       else
  96. -           perror("fopen /tmp/.timer");
  97. -#endif
  98.     }
  99.  
  100.     delete g_RCInput;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement