def command(self, cmd): """Issue an ISCP command based on the onkyo-eiscp command mappings. Args: cmd: Command to execute. """ if cmd.startswith('!1'): cmd = cmd[2:] try: cmd = '!1{}'.format(core.command_to_iscp(cmd)) except ValueError: core.iscp_to_command(cmd) cmd = '!1{}'.format(cmd) self.sendLine(cmd)
def mycb(cmd): cmd = core.iscp_to_command(cmd) if isinstance(cmd[0], tuple): cmd_name = cmd[0][0] else: cmd_name = cmd[0] cmdstr = '{}={}'.format(core.normalize_command(cmd_name), cmd[1]) self.sendLine(cmdstr)
def __loop(self): """ Polls receivers for response :return: None """ for receiver in self.receivers: response = receiver.get(timeout=0.5) try: self.tx_ready.release() except ValueError: pass if response is not None: print repr(response) print repr(iscp_to_command(response)) zone, cmd, arg = iscp_to_command(response) # parade standby as selector option if cmd in ('system-power', 'power'): if zone == 'main': cmd = 'input-selector' else: cmd = 'selector' self.rx_callback((receiver.device_name, (zone, cmd, arg)))
def lineReceived(self, line): """Handle incoming line of text from the receiver. Args: line: the line of text to process. """ # Seen some odd characters turn up at the start of serial communications. # None of these characters are part of the protocol. line = filter(lambda x: 128 > ord(x) > 32, line) if line[0:2] == '!1': cmd = core.iscp_to_command((line[2:].strip())) self.state[cmd[0]] = cmd[1] for inst in self.cb: self.cb[inst](line[2:].strip()) else: log.msg('invalid line ' + line)
def test(self): assert iscp_to_command('MVL') == ('master-volume', '')