- neutrino: fix timers from deepstandby; RTC was missing

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2019-12-28 23:42:53 +01:00
committed by Thilo Graf
parent 799aaf6728
commit d007474a48

View File

@@ -4317,18 +4317,23 @@ void CNeutrinoApp::ExitRun(int exit_code)
#endif #endif
if (exit_code != CNeutrinoApp::EXIT_REBOOT) if (exit_code != CNeutrinoApp::EXIT_REBOOT)
{ {
FILE *f;
if (timer_minutes) 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 */ /* 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) 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) if (f)
{ {
fprintf(f, "%ld\n", timer_minutes * 60); fprintf(f, "%ld\n", timer_minutes * 60);
@@ -4337,10 +4342,43 @@ void CNeutrinoApp::ExitRun(int exit_code)
else else
perror("fopen /proc/stb/fp/wakeup_time"); 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 */ /* not platform specific */
FILE *f = fopen("/tmp/.timer", "w"); f = fopen("/tmp/.timer", "w");
if (f) if (f)
{ {
fprintf(f, "%ld\n", timer_minutes ? timer_minutes * 60 : 0); fprintf(f, "%ld\n", timer_minutes ? timer_minutes * 60 : 0);