Skip to content

Commit

Permalink
- neutrino: use proc_put() to write to procfs
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhofen committed Dec 28, 2019
1 parent ee0807f commit b428762
Showing 1 changed file with 5 additions and 38 deletions.
43 changes: 5 additions & 38 deletions src/neutrino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
#include <system/setting_helpers.h>
#include <system/settings.h>
#include <system/helpers.h>
#include <system/proc_tools.h>
#include <system/sysload.h>

#include <timerdclient/timerdclient.h>
Expand Down Expand Up @@ -4439,8 +4440,6 @@ void CNeutrinoApp::ExitRun(int exit_code)
#endif
if (exit_code != CNeutrinoApp::EXIT_REBOOT)
{
FILE *f;

if (timer_minutes)
{
/* prioritize proc filesystem */
Expand All @@ -4451,56 +4450,24 @@ void CNeutrinoApp::ExitRun(int exit_code)
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)
{
f = fopen("/proc/stb/fp/wakeup_time","w");
if (f)
{
fprintf(f, "%ld\n", timer_minutes * 60);
fclose(f);
}
else
perror("fopen /proc/stb/fp/wakeup_time");
}
proc_put("/proc/stb/fp/wakeup_time", timer_minutes * 60);

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");
}
proc_put("/proc/stb/fp/rtc", t);

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");
}
proc_put("/proc/stb/fp/rtc_offset", offset);
}

/* not platform specific */
f = fopen("/tmp/.timer", "w");
FILE *f = fopen("/tmp/.timer", "w");
if (f)
{
fprintf(f, "%ld\n", timer_minutes ? timer_minutes * 60 : 0);
Expand Down

0 comments on commit b428762

Please sign in to comment.