def test_rcp_reserved(self): expect_rcp_msg = MscMessage(RCP, self.rcp_code) self.device.send_msc_message(expect_rcp_msg) expect_rcpe_msg = MscMessage(RCPE, RCP_STATUS_CODE__INEFFECTIVE_KEY_CODE) actual_rcpe_msg = self.device.recv_msc_message() self.assertEqual(actual_rcpe_msg, expect_rcpe_msg, "dut should receive rcpe %s, actual is %s" % (expect_rcpe_msg, actual_rcpe_msg)) time.sleep(5) expect_rcpk_msg = MscMessage(RCPK, self.rcp_code) actual_rcpk_msg = self.device.recv_msc_message() self.assertEqual(actual_rcpk_msg, expect_rcpk_msg, "dut should receive rcpk %s, actual is %s" % (expect_rcpk_msg, actual_rcpk_msg))
def test_rcp_supported(self): expect_rcp_msg = MscMessage(RCP, self.rcp_code) self.device.send_msc_message(expect_rcp_msg) time.sleep(3) actual_rcp_msg = self.peer_device.recv_msc_message() self.assertEqual(actual_rcp_msg, expect_rcp_msg, "peer device should receive rcp %s, actual is %s" % (expect_rcp_msg, actual_rcp_msg)) expect_rcpk_msg = MscMessage(RCPK, self.rcp_code) actual_rcpk_msg = self.device.recv_msc_message() self.assertEqual(actual_rcpk_msg, expect_rcpk_msg, "dut should receive rcpk %s, actual is %s" % (expect_rcpk_msg, actual_rcpk_msg))
def test_msc_msg_rbp_reserved(self): self.device.send_msc_message(MscMessage(RBP, self.rbp_code)) time.sleep(3) expect_rbpe_msg = MscMessage(RBPE, RBP_STATUS_CODE__INEFFECTIVE_BUTTON_CODE) actual_rbpe_msg = self.device.recv_msc_message() self.assertEqual(actual_rbpe_msg, expect_rbpe_msg, "dut should receive rbpe %s, actual is %s" % (expect_rbpe_msg, actual_rbpe_msg)) expect_rbpk_msg = MscMessage(RBPK, self.rbp_code) actual_rbpk_msg = self.device.recv_msc_message() self.assertEqual(actual_rbpk_msg, expect_rbpk_msg, "dut should receive rbpk %s, actual is %s" % (expect_rbpk_msg, actual_rbpk_msg))
def test_rap_supported(self): try: expect_rap_msg = MscMessage(RAP, self.rap_code) self.device.send_msc_message(expect_rap_msg) time.sleep(3) actual_rap_msg = self.peer_device.recv_msc_message() self.assertEqual(actual_rap_msg, expect_rap_msg, "peer device should receive rap %s, actual is %s" % (expect_rap_msg, actual_rap_msg)) expect_rapk_msg = MscMessage(RAPK, RAP_STATUS_CODE__NO_ERROR) actual_rapk_msg = self.device.recv_msc_message() self.assertEqual(actual_rapk_msg, expect_rapk_msg, "dut should receive rapk %s, actual is %s" % (expect_rapk_msg, actual_rapk_msg)) finally: self.peer_device.send_rap(0x10)
def recv_msc_message(self): type = self.read_byte(0xC0, 0xBF) code = self.read_byte(0xC0, 0xC0) if code < 0: code += 256 message = MscMessage(type, code) logger.debug("recv msc message: %s", message) return message
def test_SII9777_CBUS_EVT__MSC_SEND_SUCCESSFULLY(self): self.device.send_msc_message(MscMessage(0x10, 0x00)) pCbusEvent = Sii9777CbusEvt_t() with self.device.lock: retcode = Sii9777CbusEventQuery(self.device.drv_instance, byref(pCbusEvent)) self._test_api_retcode("Sii9777CbusEventQuery", retcode) self.assertTrue( pCbusEvent.value & SII9777_CBUS_EVT__MSC_SEND_SUCCESSFULLY, "Sii9777CbusEventQuery should get event SII9777_CBUS_EVT__MSC_SEND_SUCCESSFULLY" )
def recv_msc_message(self): msg = Sii9777MscCmd_t() with self.lock: retcode = Sii9777CbusMscMsgReceive(self.drv_instance, ctypes.byref(msg)) if retcode == 0: message = MscMessage(msg.subCmd, msg.codeValue) logger.debug("%s recv msc message: %s", self, message) return message else: logger.debug("%s recv msc message error", self) return None
def test_ucp_recv_code_read(self): self.name = ("current ucp recv is 0x%02X" % self.ucp_code) self.txunit.device.enableMSCInputDev("ucp") message = MscMessage(0x30, self.ucp_code) self.rxunit.device.send_msc_message(message) time.sleep(0.5) resp = self.txunit.device.recv_msc_message("ucp") self.assertEqual(self.ucp_code, int(resp[0], 16), "should receive same ucp code from in node") self.assertRegexpMatches( resp[1], ".*Permission denied", "should not set remote and feeback is Permission denied ")
def test_rap_recv_code_read(self): """need add Rogue as prior device to send rcp key to BA """ self.txunit.device.enableMSCInputDev("rap") message = MscMessage(0x20, self.rap_code) self.rxunit.device.send_msc_message(message) time.sleep(1) resp = self.txunit.device.recv_msc_message("rap") print "rap recv is " print resp self.assertEqual( self.rap_code, int(resp[0], 16), "should receive same rap code from in node and current node is %s" % int(resp[0], 16)) print resp[0] self.assertRegexpMatches( resp[1], ".*Permission denied", "should not set remote and feeback is Permission denied ")
def sendrcp(): print 'RCP Code 0x'+rcp_code +' will be sent after 15 seconds' time.sleep(15) expect_rcp_msg = MscMessage(RCP, int(rcp_code,16)) self.device.send_msc_message(expect_rcp_msg)
def test_mhl2_analyzer(self): global actual_rcp_msg self.resource = TestContextManager().getCurrentContext().resource #IMAGE_2D="Acer1" IMAGE_2D="CheckBy6" iface ="HDMI" qd = QD882("172.16.131.250") av_source = self.subitem.split("]_[")[0].split("[")[1] print av_source if re.search("2D",self.subitem,re.I): #av_source = self.subitem.split("]_[")[0].split("[")[1] #print av_source structure, formats, color_space, color_depth = av_source.split('_') qd.load(iface, IMAGE_2D, "/card0/Library/formats/" + formats, color_space, color_depth) elif re.search("3D",self.subitem,re.I): flag, fmt, structure, color_space, color_depth, image = av_source.split('_') qd.load_3d(image, "/card0/Library/formats/"+fmt, structure, color_space, color_depth) elif re.search("audio",self.subitem,re.I): match = re.search("(audio)_(.*)Ch_(.*)_(.*)KHz", av_source, re.I) audio_channel_number = match.group(2) # Number of channels (eg: 2, 6, 8) audio_format = match.group(3) # Format (eg: LPCM, SPDIF, Dolby etc) audio_frequency = match.group(4) # Sampling frequency (eg: 32, 44.1, 48, 88.2, 96, 176.4, 192) video_format = "720p60" video_color_space = "RGB" video_color_depth = "8" if audio_channel_number == "2": audio_type = "AudioLR" elif audio_channel_number == "6" or audio_channel_number == "8": audio_type = "Audio_Xf" else: raise ValueError("Unsupported channel number: %s" % audio_channel_number) qd.load_audio(iface, audio_type, "/card0/Library/formats/"+video_format, video_color_space, video_color_depth, audio_frequency, audio_channel_number) else: raise ValueError("Wrong subitem formats in xml!") time.sleep(5) cmd = self.subitem.split("]_[")[1].split("]")[0] print cmd cts = mhl2_analyzer(self.device_type) if re.search("RCP Transmitting",self.subitem,re.I): sp = self.subitem.find("Test_") rcp_code = self.subitem[sp+5:sp+9] def sendrcp(): print 'RCP Code 0x'+rcp_code +' will be sent after 15 seconds' time.sleep(15) expect_rcp_msg = MscMessage(RCP, int(rcp_code,16)) self.device.send_msc_message(expect_rcp_msg) t1 = Thread(target=sendrcp,args=()) t1.start() res = cts.test_mhl2_analyzer(cmd,checklog=True) for i in range (2): if res == 0: break; t1 = Thread(target=sendrcp,args=()) t1.start() res = cts.test_mhl2_analyzer(cmd) self.assertEquals(res, 0, "Return code should be \"0\" ") elif re.search("RCP Receiving",self.subitem,re.I): sp = self.subitem.find("Test_") ep = self.subitem.find("[2D") rcp_code = self.subitem[sp+5:ep] def receivercp(): global flag1 flag1 = 0 print 'DUT will try to receive RCP Code '+rcp_code time.sleep(15) actual_rcp_msg = self.device.recv_msc_message() actual_rcp_msg = str(actual_rcp_msg) #print 'Actual received msg='+actual_rcp_msg sp1 = self.subitem.find(")>") actual_rcp_code=actual_rcp_msg[30:sp1-1] print 'Actual received rcp='+actual_rcp_code if rcp_code == actual_rcp_code: # If expected rcp code is received, finished test, if not, try three times flag1 = 0 self.assertEquals(rcp_code, actual_rcp_code, "RCP Code "+rcp_code +" is received!") else: print "=======expected rcp code is NOT received=========" flag1 = 1 t1 = Thread(target=receivercp,args=()) t1.start() res = cts.test_mhl2_analyzer(cmd,checklog=True) for i in range(3): if flag1 == 0: break; if i == 2: self._fail("Expected rcp code"+rcp_code+ " is NOT received!") #self.assertEquals(1, 0, "expected rcp code is NOT received!") return t1 = Thread(target=receivercp,args=()) t1.start() res = cts.test_mhl2_analyzer(cmd,checklog=True) time.sleep(1) elif re.search("UCP Transmitting",self.subitem,re.I): sp = self.subitem.find("Test_") ucp_code = self.subitem[sp+5:sp+9] expect_ucp_msg = MscMessage(UCP, int(ucp_code,16)) self.device.send_msc_message(expect_ucp_msg) time.sleep(3) res = cts.test_mhl2_analyzer(cmd,checklog=True) self.assertEquals(res, 0, "Return code should be \"0\" ") else: res = cts.test_mhl2_analyzer(cmd,checklog=False) for i in range (2): #if not res == 0: # res = cts.test_mhl2_analyzer(cmd) if res == 0: break; res = cts.test_mhl2_analyzer(cmd) self.assertEquals(res, 0, "Return code should be \"0\" ")