fix getFPVersion for dm8000
[enigma2.git] / lib / python / Tools / DreamboxHardware.py
1 from fcntl import ioctl
2 from struct import pack, unpack
3
4 def getFPVersion():
5         ret = None
6         try:
7                 ret = long(open("/proc/stb/fp/version", "r").read())
8         except IOError:
9                 try:
10                         fp = open("/dev/dbox/fp0")
11                         ret = ioctl(fp.fileno(),0)
12                 except IOError:
13                         print "getFPVersion failed!"
14         return ret
15
16 def setFPWakeuptime(wutime):
17         try:
18                 open("/proc/stb/fp/wakeup_time", "w").write(str(wutime))
19         except IOError:
20                 try:
21                         fp = open("/dev/dbox/fp0")
22                         ioctl(fp.fileno(), 6, pack('L', wutime)) # set wake up
23                 except IOError:
24                         print "setFPWakeupTime failed!"
25
26 def getFPWakeuptime():
27         ret = 0
28         try:
29                 ret = long(open("/proc/stb/fp/wakeup_time", "r").read())
30         except IOError:
31                 try:
32                         fp = open("/dev/dbox/fp0")
33                         ret = unpack('L', ioctl(fp.fileno(), 5, '    '))[0] # get wakeuptime
34                 except IOError:
35                         print "getFPWakeupTime failed!"
36         return ret
37
38 def getFPWasTimerWakeup():
39         was_wakeup = False
40         try:
41                 was_wakeup = int(open("/proc/stb/fp/was_timer_wakeup", "r").read()) and True or False
42         except:
43                 try:
44                         fp = open("/dev/dbox/fp0")
45                         was_wakeup = unpack('B', ioctl(fp.fileno(), 9, ' '))[0] and True or False
46                 except IOError:
47                         print "wasTimerWakeup failed!"
48         return was_wakeup
49
50 def clearFPWasTimerWakeup():
51         try:
52                 open("/proc/stb/fp/was_timer_wakeup", "w").write('0')
53         except:
54                 try:
55                         fp = open("/dev/dbox/fp0")
56                         ioctl(fp.fileno(), 10)
57                 except IOError:
58                         print "clearFPWasTimerWakeup failed!"