from xml.sax import make_parser
from xml.sax.handler import ContentHandler
+def tryOpen(filename):
+ try:
+ procFile = open(filename)
+ except IOError:
+ return ""
+ return procFile
+
class SecConfigure:
def addLNBSimple(self, slotid, orbpos, toneburstmode, diseqcmode, diseqcpos):
#simple defaults
def getNimType(self, slotID):
#FIXME get it from /proc
- if slotID == 0:
- return self.nimType["DVB-S"]
- elif slotID == 1:
- return self.nimType["DVB-S"]
- else:
- return self.nimType["empty/unknown"]
+ nimfile = tryOpen("/proc/bus/nim_sockets")
+
+ if nimfile == "":
+ # FIXME: remove this in the final version
+ # check if we have a device for 7020 comp?atibility reasons
+ try:
+ open("/dev/dvb/card0/frontend" + str(slotID))
+ return self.nimType["DVB-S"]
+ except IOError:
+ return self.nimType["empty/unknown"]
+
+
+ while 1:
+ line = nimfile.readline()
+ if line == "":
+ break
+ if line.startswith("NIM Socket"):
+ parts = line.strip().split(" ")
+ id = int(parts[2][:1])
+ if id == slotID:
+ line = nimfile.readline()
+ if line == "":
+ break
+ if line.startswith(" Type:"):
+ nimfile.close()
+ return self.nimType["DVB-S"]
+ else:
+ break
+ nimfile.close()
+ return self.nimType["empty/unknown"]
def getNimName(self, slotID):
#FIXME get it from /proc
return list
def getSatListForNim(self, slotid):
- #print "slotid:", slotid
list = []
- #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
- #print "diseqcA:", config.Nims[slotid].diseqcA.value
- if (config.Nims[slotid].diseqcMode.value <= 3):
- list.append(self.satList[config.Nims[slotid].diseqcA.value])
- if (0 < config.Nims[slotid].diseqcMode.value <= 3):
- list.append(self.satList[config.Nims[slotid].diseqcB.value])
- if (config.Nims[slotid].diseqcMode.value == 3):
- list.append(self.satList[config.Nims[slotid].diseqcC.value])
- list.append(self.satList[config.Nims[slotid].diseqcD.value])
+ if (self.getNimType(slotid) != self.nimType["empty/unknown"]):
+ #print "slotid:", slotid
+
+ #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
+ #print "diseqcA:", config.Nims[slotid].diseqcA.value
+ if (config.Nims[slotid].diseqcMode.value <= 3):
+ list.append(self.satList[config.Nims[slotid].diseqcA.value])
+ if (0 < config.Nims[slotid].diseqcMode.value <= 3):
+ list.append(self.satList[config.Nims[slotid].diseqcB.value])
+ if (config.Nims[slotid].diseqcMode.value == 3):
+ list.append(self.satList[config.Nims[slotid].diseqcC.value])
+ list.append(self.satList[config.Nims[slotid].diseqcD.value])
return list
#callbacks for c++ config