def wakeup(self): from Screens.Standby import inStandby if inStandby: inStandby.Power()
def Power(self): from Screens.Standby import inStandby inStandby.Power() print "[AutoCableScan] aborted due to power button pressed" self.close(True)
def messageReceived(address, message): logcmd = "[HDMI-CEC] received cec message %x from %x" % (message, address) if logcmd: if config.hdmicec.logenabledserial.value: print logcmd if config.hdmicec.logenabledfile.value: filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) system(filelog) if config.hdmicec.enabled.value is True: from Screens.Standby import inStandby from Screens.Standby import Standby cmd = None cmdtwo = None addresstwo = None logcmd = None logcmdtwo = None physaddress1 = int( "0x" + str(config.hdmicec.tvinput.value) + str(config.hdmicec.avinput.value), 16) physaddress2 = int("0x00", 16) addresstv = int("0x00", 16) addressav = int("0x05", 16) addressglobal = int("0x0F", 16) powerstatereportmessage = int("0x90", 16) powerstate = int("0x00", 16) physaddressmessage = int('0x84', 16) devicetypmessage = int('0x03', 16) activesourcemessage = int('0x82', 16) menuonmessage = int('0x8E', 16) menustatemessage = int('0x00', 16) setnamemessage = int('0x47', 16) sendkeymessage = int("44", 16) sendkeypwronmessage = int("6D", 16) sendkeypwroffmessage = int("6C", 16) if message == 0x8f: # request power state address = addresstv cecmessage = powerstatereportmessage cecmessagetwo = powerstate cmd = struct.pack('BB', cecmessage, cecmessagetwo) logcmd = "[HDMI-CEC] send cec message %x:%x to %x" % ( cecmessage, cecmessagetwo, address) elif message == 0x83: # request physical address address = addressglobal cecmessage = physaddressmessage cecmessagetwo = physaddress1 cecmessagethree = physaddress2 cecmessagefour = devicetypmessage cmd = struct.pack('BBBB', cecmessage, cecmessagetwo, cecmessagethree, cecmessagefour) logcmd = "[HDMI-CEC] send cec message %x:%x:%x:%x to %x" % ( cecmessage, cecmessagetwo, cecmessagethree, cecmessagefour, address) elif message == 0x86: # request streampath address = addressglobal cecmessage = activesourcemessage cecmessagetwo = physaddress1 cecmessagethree = physaddress2 cmd = struct.pack('BBB', cecmessage, cecmessagetwo, cecmessagethree) logcmd = "[HDMI-CEC] send cec message %x:%x:%x to %x" % ( cecmessage, cecmessagetwo, cecmessagethree, address) if config.hdmicec.enabletvrc.value: addresstwo = addresstv cecmessage = menuonmessage cecmessagetwo = menustatemessage cmdtwo = struct.pack('BB', cecmessage, cecmessagetwo) logcmdtwo = "[HDMI-CEC] send cec message %x:%x to %x" % ( cecmessage, cecmessagetwo, address) elif message == 0x8d: # request menu state if config.hdmicec.enabletvrc.value: address = addresstv cecmessage = menuonmessage cecmessagetwo = menustatemessage cmd = struct.pack('BB', cecmessage, cecmessagetwo) logcmd = "[HDMI-CEC] send cec message %x:%x to %x" % ( cecmessage, cecmessagetwo, address) elif message == 0x46: # request device name address = addresstv cecmessage = setnamemessage name_len = len(config.hdmicec.devicename.value) if name_len == 0: cecmessagetwo = "VU+" cmd = struct.pack('B4s', cecmessage, cecmessagetwo) else: cecmessagetwo = config.hdmicec.devicename.value cmd = struct.pack('B' + str(name_len + 1) + 's', cecmessage, cecmessagetwo) logcmd = "[HDMI-CEC] send cec message %x:%s to %x" % ( cecmessage, cecmessagetwo, address) elif message == 0x85: # request active source if not inStandby: address = addressglobal cecmessage = activesourcemessage cecmessagetwo = physaddress1 cecmessagethree = physaddress2 cmd = struct.pack('BBB', cecmessage, cecmessagetwo, cecmessagethree) logcmd = "[HDMI-CEC] send cec message %x:%x:%x to %x" % ( cecmessage, cecmessagetwo, cecmessagethree, address) if config.hdmicec.enabletvrc.value: addresstwo = addresstv cecmessage = menuonmessage cecmessagetwo = menustatemessage cmdtwo = struct.pack('BB', cecmessage, cecmessagetwo) logcmdtwo = "[HDMI-CEC] send cec message %x:%x to %x" % ( cecmessage, cecmessagetwo, address) elif inStandby: if config.hdmicec.vuwakeup_message.value == "vuwakeup": inStandby.Power() address = addressglobal cecmessage = activesourcemessage cecmessagetwo = physaddress1 cecmessagethree = physaddress2 cmd = struct.pack('BBB', cecmessage, cecmessagetwo, cecmessagethree) logcmd = "[HDMI-CEC] send cec message %x:%x:%x to %x" % ( cecmessage, cecmessagetwo, cecmessagethree, address) if config.hdmicec.enabletvrc.value: addresstwo = addresstv cecmessage = menuonmessage cecmessagetwo = menustatemessage cmdtwo = struct.pack('BB', cecmessage, cecmessagetwo) logcmdtwo = "[HDMI-CEC] send cec message %x:%x to %x" % ( cecmessage, cecmessagetwo, address) elif message == 0x36: if config.hdmicec.vustandby_message.value == "vustandby": if inStandby == None: logcmd = "[HDMI-CEC] VU+ STB goto standby" session.open(Standby) elif config.hdmicec.vustandby_message.value == "vudeepstandby": import Screens.Standby logcmd = "[HDMI-CEC] VU+ STB goto deepstandby" session.open(Screens.Standby.TryQuitMainloop, 1) if cmd: eHdmiCEC.getInstance().sendMessage(address, len(cmd), str(cmd)) if cmdtwo: eHdmiCEC.getInstance().sendMessage(addresstwo, len(cmdtwo), str(cmdtwo)) if logcmd: if config.hdmicec.logenabledserial.value: print logcmd if config.hdmicec.logenabledfile.value: filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) system(filelog) if logcmdtwo: if config.hdmicec.logenabledserial.value: print logcmdtwo if config.hdmicec.logenabledfile.value: filelog = "echo %s >> /tmp/hdmicec.log" % (logcmdtwo) system(filelog)
def wakeup(self): self.wakeup_from_tv = True from Screens.Standby import inStandby if inStandby: inStandby.Power()
def getText(self): if self.cmd == "" or self.cmd is None: return self.getStandby() #-1: get current state # 0: toggle standby # 1: poweroff/deepstandby # 2: rebootdreambox # 3: rebootenigma # 4: wakeup (if not already awake) # 5: standby # 6: kill enigma2 try: from Screens.Standby import inStandby from Screens.Standby import Standby type = int(self.cmd) if type == -1: return self.getStandby() elif type == 0: print("[PowerState.py] Standby 0") if inStandby is None: self.session.open(Standby) return "true" else: inStandby.Power() return "false" elif type == 4: print("[PowerState.py] Standby 4") if inStandby is not None: inStandby.Power() return "false" else: return "true" elif type == 5: print("[PowerState.py] Standby 5") if inStandby is None: self.session.open(Standby) return "true" else: return "false" elif type == 6: print("[PowerState.py] Standby 6") from twisted.internet import reactor import os reactor.callLater(1, os.popen, 'killall -9 enigma2') return "true" elif 0 < type < 4: print("[PowerState.py] TryQuitMainloop") from Screens.Standby import TryQuitMainloop from twisted.internet import reactor reactor.callLater(1, self.session.open, TryQuitMainloop, type) return "true" else: print("[PowerState.py] cmd unknown" % type) return "error" except ValueError: return "error"
def Power(self): from Screens.Standby import inStandby inStandby.Power() print("[FastScan] aborted due to power button pressed") self.close(True)
def gotThreadMsg(msg): _msg = globalvars.HttpDeamonThread.PlayerData.pop() data = _msg[0] print("data ==>") print(str(data)) # first we check if we are standby and exit this if needed if inStandby is not None: inStandby.Power() if "command" in data: command = data["command"] if command == "startNotifier": startNotifier() elif command == "playMedia": if data["currentKey"] != globalvars.lastKey: startPlayback(data) else: print("dropping mediaplay command ...") globalvars.lastKey = data["currentKey"] elif command == "pause": if isinstance(globalvars.global_session.current_dialog, DP_Player): globalvars.global_session.current_dialog.pauseService() elif command == "play": if isinstance(globalvars.global_session.current_dialog, DP_Player): globalvars.global_session.current_dialog.unPauseService() elif command == "skipNext": globalvars.global_session.current_dialog.playNextEntry() elif command == "skipPrevious": globalvars.global_session.current_dialog.playPreviousEntry() elif command == "stepForward": globalvars.global_session.current_dialog.seekFwd() elif command == "stepBack": globalvars.global_session.current_dialog.seekBack() elif command == "seekTo": offset = int(data["offset"]) * 90000 globalvars.global_session.current_dialog.doSeek(offset) elif command == "setVolume": if isinstance(globalvars.global_session.current_dialog, DP_Player): globalvars.global_session.current_dialog.setVolume( int(data["volume"])) elif command == "stop": globalvars.lastKey = None stopPlayback(restartLiveTv=True) elif command == "addSubscriber": print("subscriber") protocol = data["protocol"] host = data["host"] port = data["port"] uuid = data["uuid"] commandID = data["commandID"] globalvars.HttpDeamonThread.addSubscriber(protocol, host, port, uuid, commandID) startNotifier() elif command == "removeSubscriber": print("remove subscriber") uuid = data["uuid"] globalvars.HttpDeamonThread.removeSubscriber(uuid) updateNotifier() elif command == "updateCommandId": uuid = data["uuid"] commandID = data["commandID"] globalvars.HttpDeamonThread.updateCommandID(uuid, commandID) elif command == "idle": pass else: # not handled command print(command) raise Exception
def messageReceived(cecdata, manual_address=None, manual_cmd=None): global log data = 16 * '\x00' length = 0 if cecdata is not None: message = cecdata.getCommand() address = cecdata.getAddress() length = cecdata.getData(data, len(data)) elif manual_address is not None and manual_cmd is not None: message = manual_cmd address = manual_address #logcmd = lineno()+"received cec message %x from %x" % (message, address) logcmd = lineno() + "%1x>%1x %02x (%s)" % ( address & 0xF, address >> 4, message, CecMsg.get(message, "Unknown Message")) for ci in range(length): logcmd += " %02x" % ord(data[ci]) if config.hdmicec.logenabledserial.value: vtilog("[HDMICEC] " + logcmd) #if config.hdmicec.logenabledfile.value: # filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) # system(filelog) if hdmi_cec.log: hdmi_cec.log.info(logcmd) if config.hdmicec.enabled.value: from Screens.Standby import inStandby from Screens.Standby import Standby cmd = None cmdtwo = None addresstwo = None logcmd = None logcmdtwo = None physaddress1 = int("0x" + str(config.hdmicec.tvinput.value) + "0", 16) physaddress2 = int("0x00", 16) addresstv = int("0x00", 16) addressav = int("0x05", 16) addressglobal = int("0x0F", 16) cecversionreportmessage = int("0x9E", 16) cecversionmessage = int("0x04", 16) powerstatereportmessage = int("0x90", 16) powerstateOff = int("0x01", 16) powerstateOn = int("0x00", 16) physaddressmessage = int('0x84', 16) devicetypmessage = int('0x01', 16) activesourcemessage = int('0x82', 16) vendoridmessage = int('0x87', 16) menuonmessage = int('0x8E', 16) menustatemessage = int('0x00', 16) setnamemessage = int('0x47', 16) sendkeymessage = int("44", 16) sendkeypwronmessage = int("6D", 16) sendkeypwroffmessage = int("6C", 16) if message == 0x8f: # request power state address = addresstv cecmessage = powerstatereportmessage cecmessagetwo = powerstateOn if (inStandby) and (config.hdmicec.vuwakeup_message.value == "vuwakeup"): cecmessagetwo = powerstateOff cmd = struct.pack('BB', cecmessage, cecmessagetwo) logcmd = lineno() + "** send cec %x:%x -> %x" % ( cecmessage, cecmessagetwo, address) if message == 0x9f: # request cec version address = addresstv cecmessage = cecversionreportmessage cecmessagetwo = cecversionmessage cmd = struct.pack('BB', cecmessage, cecmessagetwo) logcmd = lineno() + "** send cec %x:%x -> %x" % ( cecmessage, cecmessagetwo, address) elif message == 0x83: # request physical address if (inStandby) and (config.hdmicec.vuwakeup_message.value == "vuwakeup"): inStandby.Power() address = addressglobal cecmessage = physaddressmessage cecmessagetwo = physaddress1 cecmessagethree = physaddress2 cecmessagefour = devicetypmessage cmd = struct.pack('BBBB', cecmessage, cecmessagetwo, cecmessagethree, cecmessagefour) logcmd = lineno() + "** send cec %x:%x:%x:%x -> %x" % ( cecmessage, cecmessagetwo, cecmessagethree, cecmessagefour, address) elif message == 0x86: physicaladdress = ord(data[0]) * 256 + ord(data[1]) pysaddrrstr = "%x" % (physicaladdress) confAddress = "%x%02x" % (physaddress1, physaddress2) if pysaddrrstr == confAddress: if (inStandby) and (config.hdmicec.vuwakeup_message.value == "vuwakeup"): inStandby.Power() address = addressglobal cecmessage = activesourcemessage cecmessagetwo = physaddress1 cecmessagethree = physaddress2 cmd = struct.pack('BBB', cecmessage, cecmessagetwo, cecmessagethree) logcmd = lineno() + "** send cec %x:%x:%x -> %x" % ( cecmessage, cecmessagetwo, cecmessagethree, address) eHdmiCEC.getInstance().sendMessage(address, len(cmd), str(cmd)) if config.hdmicec.enabletvrc.value: addresstwo = addresstv cecmessage = menuonmessage cecmessagetwo = menustatemessage cmdtwo = struct.pack('BB', cecmessage, cecmessagetwo) eHdmiCEC.getInstance().sendMessage(addresstwo, len(cmdtwo), str(cmdtwo)) else: logcmd = lineno() + "received %x with data %x my conf %s" % ( message, physicaladdress, confAddress) elif message == 0x8d: # request menu state if config.hdmicec.enabletvrc.value: address = addresstv cecmessage = menuonmessage cecmessagetwo = menustatemessage cmd = struct.pack('BB', cecmessage, cecmessagetwo) logcmd = lineno() + "** send cec %x:%x -> %x" % ( cecmessage, cecmessagetwo, address) elif message == 0x46: # request device name address = addresstv cecmessage = setnamemessage name_len = len(config.hdmicec.device_name.value) if name_len == 0: cecmessagetwo = "VU+" cmd = struct.pack('B4s', cecmessage, cecmessagetwo) else: cecmessagetwo = config.hdmicec.device_name.value cmd = struct.pack('B' + str(name_len + 1) + 's', cecmessage, cecmessagetwo) logcmd = lineno() + "** send cec %x:%s -> %x" % ( cecmessage, cecmessagetwo, address) elif message == 0x85: # request active source if not inStandby: if config.hdmicec.active_source_reply.value or hdmi_cec.initial_active_source_call == True: address = addressglobal cecmessage = activesourcemessage cecmessagetwo = physaddress1 cecmessagethree = physaddress2 cmd = struct.pack('BBB', cecmessage, cecmessagetwo, cecmessagethree) logcmd = lineno() + "** send cec %x:%x:%x -> %x" % ( cecmessage, cecmessagetwo, cecmessagethree, address) if config.hdmicec.enabletvrc.value: addresstwo = addresstv cecmessage = menuonmessage cecmessagetwo = menustatemessage cmdtwo = struct.pack('BB', cecmessage, cecmessagetwo) logcmdtwo = lineno() + "** send cec %x:%x -> %x" % ( cecmessage, cecmessagetwo, address) elif inStandby: if config.hdmicec.vuwakeup_message.value == "vuwakeup": inStandby.Power() address = addressglobal cecmessage = activesourcemessage cecmessagetwo = physaddress1 cecmessagethree = physaddress2 cmd = struct.pack('BBB', cecmessage, cecmessagetwo, cecmessagethree) logcmd = lineno() + "** send cec %x:%x:%x -> %x" % ( cecmessage, cecmessagetwo, cecmessagethree, address) if config.hdmicec.enabletvrc.value: addresstwo = addresstv cecmessage = menuonmessage cecmessagetwo = menustatemessage cmdtwo = struct.pack('BB', cecmessage, cecmessagetwo) logcmdtwo = lineno() + "** send cec %x:%x -> %x" % ( cecmessage, cecmessagetwo, address) elif message == 0x36: if config.hdmicec.vustandby_message.value == "vustandby": if inStandby == None: logcmd = lineno() + "VU+ STB goto standby" session.open(Standby) elif config.hdmicec.vustandby_message.value == "vudeepstandby": import Screens.Standby logcmd = lineno() + "VU+ STB goto deepstandby" session.open(Screens.Standby.TryQuitMainloop, 1) if inStandby == None: if cmd: eHdmiCEC.getInstance().sendMessage(address, len(cmd), str(cmd)) if cmdtwo: eHdmiCEC.getInstance().sendMessage(addresstwo, len(cmdtwo), str(cmdtwo)) if logcmd: if config.hdmicec.logenabledserial.value: vtilog("[HDMICEC] " + logcmd) #if config.hdmicec.logenabledfile.value: # filelog = "echo %s >> /tmp/hdmicec.log" % (logcmd) # system(filelog) if hdmi_cec.log: hdmi_cec.log.info(logcmd) if logcmdtwo: if config.hdmicec.logenabledserial.value: vtilog("[HDMICEC] " + logcmdtwo) #if config.hdmicec.logenabledfile.value: # filelog = "echo %s >> /tmp/hdmicec.log" % (logcmdtwo) # system(filelog) if hdmi_cec.log: hdmi_cec.log.info(logcmdtwo)
def getText(self): if self.cmd == "" or self.cmd is None: return self.getStandby() #-1: get current state # 0: toggle standby # 1: poweroff/standby # 2: rebootdreambox # 3: rebootenigma # 4: wakeup (if not already awake) # 5: idle mode # 6: kill enigma2 try: from Screens.Standby import inStandby from Screens.Standby import Standby type = int(self.cmd) if type == -1: return self.getStandby() elif type == 0: print "[PowerState.py] Standby 0" if inStandby is None: self.session.open(Standby) return "true" else: inStandby.Power() return "false" elif type == 4: print "[PowerState.py] Standby 4" if inStandby is not None: inStandby.Power() return "false" else: return "true" elif type == 5: print "[PowerState.py] Standby 5" if inStandby is None: self.session.open(Standby) return "true" else: return "false" elif type == 6: print "[PowerState.py] Standby 6" from twisted.internet import reactor from subprocess import call # XXX: SIGKILL? Really? reactor.callLater(1, call, ['killall', '-9', 'enigma2']) return "true" elif 0 < type < 4: print "[PowerState.py] TryQuitMainloop" from Screens.Standby import TryQuitMainloop from twisted.internet import reactor reactor.callLater(1, self.session.open, TryQuitMainloop, type) return "true" else: print "[PowerState.py] cmd unknown" % type return "error" except ValueError: return "error"