mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
- shutdown_helper: better explanation of what the tool does; ...
small code re-formatting Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* shutdown_helper - switch off the box with a possible timer wakeup
|
* shutdown_helper - send current time, wakeup time,
|
||||||
* this is needed because the drivers do not implement a proper
|
* led and bright settings to coolstream's frontpanel
|
||||||
* hwclock interface :-(
|
* and switch off the box
|
||||||
*
|
*
|
||||||
* (C) 2013-2014 Stefan Seyfried
|
* (C) 2013-2014 Stefan Seyfried
|
||||||
*
|
*
|
||||||
@@ -29,7 +29,8 @@ int main(int argc, char **argv)
|
|||||||
struct tm *tmnow = localtime(&now);
|
struct tm *tmnow = localtime(&now);
|
||||||
time_t fp_timer = 0;
|
time_t fp_timer = 0;
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3)
|
||||||
|
{
|
||||||
fprintf(stderr, "need timer_seconds, led and brightness values\n");
|
fprintf(stderr, "need timer_seconds, led and brightness values\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -38,15 +39,16 @@ int main(int argc, char **argv)
|
|||||||
leds = atoi(argv[2]);
|
leds = atoi(argv[2]);
|
||||||
brightness = atoi(argv[3]);
|
brightness = atoi(argv[3]);
|
||||||
|
|
||||||
if (timer_seconds) {
|
if (timer_seconds)
|
||||||
|
{
|
||||||
fp_timer = (timer_seconds - now) / 60;
|
fp_timer = (timer_seconds - now) / 60;
|
||||||
if (fp_timer < 1) {
|
if (fp_timer < 1)
|
||||||
fprintf(stderr, "warning: interval less than 1 minute (%d s) correcting\n",
|
{
|
||||||
(int)(timer_seconds - now));
|
fprintf(stderr, "warning: interval less than 1 minute (%d s) correcting\n", (int)(timer_seconds - now));
|
||||||
fp_timer = 1;
|
fp_timer = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr, "now: %ld, timer %ld, FP timer %ldmin\n\n", now / 60, timer_seconds / 60, fp_timer);
|
fprintf(stderr, "now: %ld, timer %ld, FP timer %ldmin\n", now / 60, timer_seconds / 60, fp_timer);
|
||||||
|
|
||||||
fp.brightness = brightness;
|
fp.brightness = brightness;
|
||||||
fp.flags = leds;
|
fp.flags = leds;
|
||||||
@@ -56,15 +58,19 @@ int main(int argc, char **argv)
|
|||||||
fp.timer_minutes_lo = fp_timer & 0xFF;
|
fp.timer_minutes_lo = fp_timer & 0xFF;
|
||||||
|
|
||||||
fd = open("/dev/display", O_RDONLY);
|
fd = open("/dev/display", O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd >= 0)
|
||||||
perror("/dev/display");
|
{
|
||||||
else {
|
if (ioctl(fd, IOC_FP_STANDBY, (fp_standby_data_t *) &fp) == 0)
|
||||||
if (ioctl(fd, IOC_FP_STANDBY, (fp_standby_data_t *) &fp))
|
{
|
||||||
perror("IOC_FP_STANDBY");
|
fprintf(stderr, "halt now\n");
|
||||||
else {
|
|
||||||
while (1)
|
while (1)
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
perror("IOC_FP_STANDBY");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
perror("/dev/display");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user