mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 17:01:15 +02:00
coolstream: align shutdown handling with other archs
instead of just running rcK (which might not exist) and then switching off the box hard, exit with proper exit code and let a helper binary shut off the box with wakeup timer in a shutdown script.
This commit is contained in:
@@ -155,6 +155,8 @@ neutrino_LDADD += \
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if BOXTYPE_COOL
|
if BOXTYPE_COOL
|
||||||
|
bin_PROGRAMS += uncooloff
|
||||||
|
uncooloff_SOURCES = uncooloff.c
|
||||||
if BOXMODEL_APOLLO
|
if BOXMODEL_APOLLO
|
||||||
else
|
else
|
||||||
noinst_PROGRAMS = uncoolinit
|
noinst_PROGRAMS = uncoolinit
|
||||||
|
@@ -3186,7 +3186,7 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode)
|
|||||||
g_settings.shutdown_timer_record_type = timer_is_rec;
|
g_settings.shutdown_timer_record_type = timer_is_rec;
|
||||||
saveSetup(NEUTRINO_SETTINGS_FILE);
|
saveSetup(NEUTRINO_SETTINGS_FILE);
|
||||||
|
|
||||||
#if HAVE_COOL_HARDWARE
|
#if 0
|
||||||
if(retcode) {
|
if(retcode) {
|
||||||
#endif
|
#endif
|
||||||
puts("[neutrino.cpp] executing " NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT ".");
|
puts("[neutrino.cpp] executing " NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT ".");
|
||||||
@@ -3198,7 +3198,7 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode)
|
|||||||
mode = mode_off;
|
mode = mode_off;
|
||||||
//CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_MAINMENU_SHUTDOWN));
|
//CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_MAINMENU_SHUTDOWN));
|
||||||
|
|
||||||
#if HAVE_COOL_HARDWARE
|
#if 0
|
||||||
my_system("/etc/init.d/rcK");
|
my_system("/etc/init.d/rcK");
|
||||||
sync();
|
sync();
|
||||||
my_system(2,"/bin/umount", "-a");
|
my_system(2,"/bin/umount", "-a");
|
||||||
@@ -3260,13 +3260,42 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
if (timer_minutes)
|
int leds = 0;
|
||||||
|
int bright = 0;
|
||||||
|
#if HAVE_COOL_HARDWARE
|
||||||
|
if (retcode) {
|
||||||
|
leds = 0x40;
|
||||||
|
switch (g_settings.led_deep_mode){
|
||||||
|
case 0:
|
||||||
|
leds = 0x0;//off leds
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
leds = 0x60;//on led1 & 2
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
leds = 0x20;//led1 on , 2 off
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
leds = 0x40;//led2 off, 2 on
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (leds && g_settings.led_blink && timer_minutes)
|
||||||
|
leds |= 0x80;
|
||||||
|
}
|
||||||
|
if (cs_get_revision() != 10)
|
||||||
|
bright = g_settings.lcd_setting[SNeutrinoSettings::LCD_DEEPSTANDBY_BRIGHTNESS];
|
||||||
|
#endif
|
||||||
|
if (timer_minutes || leds)
|
||||||
{
|
{
|
||||||
FILE *f = fopen("/tmp/.timer", "w");
|
FILE *f = fopen("/tmp/.timer", "w");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "timer_wakeup: %ld\n", timer_minutes * 60);
|
fprintf(stderr, "timer_wakeup: %ld\n", timer_minutes * 60);
|
||||||
fprintf(f, "%ld\n", timer_minutes * 60);
|
fprintf(f, "%ld\n", timer_minutes * 60);
|
||||||
|
fprintf(f, "%d\n", leds);
|
||||||
|
fprintf(f, "%d\n", bright);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3292,7 +3321,7 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode)
|
|||||||
#else
|
#else
|
||||||
exit(retcode);
|
exit(retcode);
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_COOL_HARDWARE
|
#if 0
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
67
src/uncooloff.c
Normal file
67
src/uncooloff.c
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* uncooloff - switch off the box with a possible timer wakeup
|
||||||
|
* this is needed because the drivers do not implement a proper
|
||||||
|
* hwclock interface :-(
|
||||||
|
*
|
||||||
|
* (C) 2013 Stefan Seyfried
|
||||||
|
*
|
||||||
|
* License: GPLv2+
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <linux/ioctl.h>
|
||||||
|
|
||||||
|
#include <cs_frontpanel.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int leds;
|
||||||
|
int brightness;
|
||||||
|
fp_standby_data_t fp;
|
||||||
|
time_t timer_seconds;
|
||||||
|
time_t now = time(NULL);
|
||||||
|
struct tm *tmnow = localtime(&now);
|
||||||
|
time_t fp_timer = 0;
|
||||||
|
|
||||||
|
if (argc < 3) {
|
||||||
|
fprintf(stderr, "need timer_seconds, led and brightness values\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
timer_seconds = atol(argv[1]);
|
||||||
|
leds = atoi(argv[2]);
|
||||||
|
brightness = atoi(argv[3]);
|
||||||
|
|
||||||
|
if (timer_seconds) {
|
||||||
|
fp_timer = (timer_seconds - now) / 60;
|
||||||
|
if (fp_timer < 1) {
|
||||||
|
fprintf(stderr, "warning: interval less than 1 minute (%d s) correcting\n",
|
||||||
|
(timer_seconds - now));
|
||||||
|
fp_timer = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stderr, "now: %ld, timer %ld, FP timer %ldmin\n\n", now / 60, timer_seconds / 60, fp_timer);
|
||||||
|
|
||||||
|
fp.brightness = brightness;
|
||||||
|
fp.flags = leds;
|
||||||
|
fp.current_hour = tmnow->tm_hour;
|
||||||
|
fp.current_minute = tmnow->tm_min;
|
||||||
|
fp.timer_minutes_hi = fp_timer >> 8;;
|
||||||
|
fp.timer_minutes_lo = fp_timer & 0xFF;
|
||||||
|
|
||||||
|
fd = open("/dev/display", O_RDONLY);
|
||||||
|
if (fd < 0)
|
||||||
|
perror("/dev/display");
|
||||||
|
else {
|
||||||
|
if (ioctl(fd, IOC_FP_STANDBY, (fp_standby_data_t *) &fp))
|
||||||
|
perror("IOC_FP_STANDBY");
|
||||||
|
else {
|
||||||
|
while (1)
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
Reference in New Issue
Block a user