From d007474a482f09b8d453ed16e7db6c280cf0984d Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Sat, 28 Dec 2019 23:42:53 +0100 Subject: [PATCH] - neutrino: fix timers from deepstandby; RTC was missing Signed-off-by: Thilo Graf --- src/neutrino.cpp | 54 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index aaf9eba1a..4da151173 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -4317,18 +4317,23 @@ void CNeutrinoApp::ExitRun(int exit_code) #endif if (exit_code != CNeutrinoApp::EXIT_REBOOT) { + FILE *f; + if (timer_minutes) { - time_t t = timer_minutes * 60; - struct tm *tm = localtime(&t); - char date[30]; - strftime(date, sizeof(date), "%c", tm); - printf("wakeup_time: %s (%ld)\n", date, timer_minutes * 60); - /* prioritize proc filesystem */ + + time_t t = timer_minutes * 60; + struct tm *lt = localtime(&t); + char date[30]; + strftime(date, sizeof(date), "%c", lt); + printf("wakeup time : %s (%ld)\n", date, timer_minutes * 60); + + // FIXME: use proc_put() + if (access("/proc/stb/fp/wakeup_time", F_OK) == 0) { - FILE *f = fopen("/proc/stb/fp/wakeup_time","w"); + f = fopen("/proc/stb/fp/wakeup_time","w"); if (f) { fprintf(f, "%ld\n", timer_minutes * 60); @@ -4337,10 +4342,43 @@ void CNeutrinoApp::ExitRun(int exit_code) else perror("fopen /proc/stb/fp/wakeup_time"); } + + t = time(NULL); + lt = localtime(&t); + strftime(date, sizeof(date), "%c", lt); + printf("current time: %s (%ld)\n", date, t); + + if (access("/proc/stb/fp/rtc", F_OK) == 0) + { + f = fopen("/proc/stb/fp/rtc","w"); + if (f) + { + fprintf(f, "%ld\n", t); + fclose(f); + } + else + perror("fopen /proc/stb/fp/rtc"); + } + + struct tm *gt = gmtime(&t); + int offset = (lt->tm_hour - gt->tm_hour) * 3600; + printf("rtc_offset : %d\n", offset); + + if (access("/proc/stb/fp/rtc_offset", F_OK) == 0) + { + f = fopen("/proc/stb/fp/rtc_offset","w"); + if (f) + { + fprintf(f, "%d\n", offset); + fclose(f); + } + else + perror("fopen /proc/stb/fp/rtc_offset"); + } } /* not platform specific */ - FILE *f = fopen("/tmp/.timer", "w"); + f = fopen("/tmp/.timer", "w"); if (f) { fprintf(f, "%ld\n", timer_minutes ? timer_minutes * 60 : 0);