Merge branch 'master' of git.opendreambox.org:/git/enigma2
authorghost <andreas.monzner@multimedia-labs.de>
Wed, 4 Mar 2009 23:12:49 +0000 (00:12 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Wed, 4 Mar 2009 23:12:49 +0000 (00:12 +0100)
lib/dvb/dvbtime.cpp
lib/python/Tools/DreamboxHardware.py
mytest.py

index 03847ec..a6830dc 100644 (file)
@@ -20,7 +20,7 @@ void setRTC(time_t time)
        FILE *f = fopen("/proc/stb/fp/rtc", "w");
        if (f)
        {
-               if (fprintf(f, "%u", time))
+               if (fprintf(f, "%u", (unsigned int)time))
                        prev_time = time;
                else
                        eDebug("write /proc/stb/fp/rtc failed (%m)");
@@ -47,8 +47,11 @@ time_t getRTC()
        if (f)
        {
                // sanity check to detect corrupt atmel firmware
-               if (fscanf(f, "%u", &rtc_time) != 1)
+               unsigned int tmp;
+               if (fscanf(f, "%u", &tmp) != 1)
                        eDebug("read /proc/stb/fp/rtc failed (%m)");
+               else
+                       rtc_time=tmp;
                fclose(f);
        }
        else
index 5461f7b..9e81bb4 100644 (file)
@@ -23,6 +23,16 @@ def setFPWakeuptime(wutime):
                except IOError:
                        print "setFPWakeupTime failed!"
 
+def setRTCtime(wutime):
+       try:
+               open("/proc/stb/fp/rtc", "w").write(str(wutime))
+       except IOError:
+               try:
+                       fp = open("/dev/dbox/fp0")
+                       ioctl(fp.fileno(), 0x101, pack('L', wutime)) # set wake up
+               except IOError:
+                       print "setRTCtime failed!"
+
 def getFPWakeuptime():
        ret = 0
        try:
index 261ff2a..b58ec2d 100755 (executable)
--- a/mytest.py
+++ b/mytest.py
@@ -466,8 +466,8 @@ def runScreenTest():
        runReactor()
 
        profile("wakeup")
-       from time import time
-       from Tools.DreamboxHardware import setFPWakeuptime, getFPWakeuptime
+       from time import time, strftime, localtime
+       from Tools.DreamboxHardware import setFPWakeuptime, getFPWakeuptime, setRTCtime
        #get currentTime
        nowTime = time()
        wakeupList = [
@@ -479,11 +479,16 @@ def runScreenTest():
        wakeupList.sort()
        recordTimerWakeupAuto = False
        if wakeupList:
+               from time import strftime
                startTime = wakeupList[0]
                if (startTime[0] - nowTime) < 330: # no time to switch box back on
                        wptime = nowTime + 30  # so switch back on in 30 seconds
                else:
                        wptime = startTime[0] - 300
+               if not config.misc.useTransponderTime.value:
+                       print "dvb time sync disabled... so set RTC now to current linux time!", strftime("%Y/%m/%d %H:%M", localtime(nowTime))
+                       setRTCtime(nowTime)
+               print "set wakeup time to", strftime("%Y/%m/%d %H:%M", localtime(wptime))
                setFPWakeuptime(wptime)
                recordTimerWakeupAuto = startTime[1] == 0 and startTime[2]
        config.misc.isNextRecordTimerAfterEventActionAuto.value = recordTimerWakeupAuto