main/Makefile.am: fix code to generate version.h code is now als able to handle git...
[enigma2.git] / lib / python / Tools / DreamboxHardware.py
index 5eaaeecaba7fbd8eef7cc0d0b95e4e2de206e970..9e81bb476a564e9a72cef9ab8e31eb450da723df 100644 (file)
@@ -1,17 +1,68 @@
+from fcntl import ioctl
+from struct import pack, unpack
+
 def getFPVersion():
-       from fcntl import ioctl
+       ret = None
        try:
-               fp = open("/dev/dbox/fp0")
-               return ioctl(fp.fileno(),0)
+               ret = long(open("/proc/stb/fp/version", "r").read())
        except IOError:
-               return None
+               try:
+                       fp = open("/dev/dbox/fp0")
+                       ret = ioctl(fp.fileno(),0)
+               except IOError:
+                       print "getFPVersion failed!"
+       return ret
 
 def setFPWakeuptime(wutime):
-       from fcntl import ioctl
-       from struct import pack
+       try:
+               open("/proc/stb/fp/wakeup_time", "w").write(str(wutime))
+       except IOError:
+               try:
+                       fp = open("/dev/dbox/fp0")
+                       ioctl(fp.fileno(), 6, pack('L', wutime)) # set wake up
+               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:
-               fp = open("/dev/dbox/fp0")
-               ioctl(fp.fileno(), 6, pack('L', wutime)) # set wake up
+               ret = long(open("/proc/stb/fp/wakeup_time", "r").read())
        except IOError:
-               pass    
+               try:
+                       fp = open("/dev/dbox/fp0")
+                       ret = unpack('L', ioctl(fp.fileno(), 5, '    '))[0] # get wakeuptime
+               except IOError:
+                       print "getFPWakeupTime failed!"
+       return ret
+
+def getFPWasTimerWakeup():
+       was_wakeup = False
+       try:
+               was_wakeup = int(open("/proc/stb/fp/was_timer_wakeup", "r").read()) and True or False
+       except:
+               try:
+                       fp = open("/dev/dbox/fp0")
+                       was_wakeup = unpack('B', ioctl(fp.fileno(), 9, ' '))[0] and True or False
+               except IOError:
+                       print "wasTimerWakeup failed!"
+       return was_wakeup
+
+def clearFPWasTimerWakeup():
+       try:
+               open("/proc/stb/fp/was_timer_wakeup", "w").write('0')
+       except:
+               try:
+                       fp = open("/dev/dbox/fp0")
+                       ioctl(fp.fileno(), 10)
+               except IOError:
+                       print "clearFPWasTimerWakeup failed!"