def send_apdu(self, apdu_text, tmn_addr='', logic_addr=-1, chan_index=-1, C_text='43'): """apdu to compelete msg to send""" if self.is_plaintext_rn: # 10 + 00 + len + apdu + 0110 5FE30D32D6A20288F9112B5C6052CFDB(fixme: 先固定一个随机数) apdu_len = len(common.text2list(apdu_text)) apdu_head = '1000' #安全请求+明文应用数据单元 if apdu_len < 128: apdu_head += "%02X"%apdu_len elif apdu_len < 256: apdu_head += "81%02X"%apdu_len else: apdu_head += "82%04X"%apdu_len apdu_text = apdu_head + apdu_text + '0110 5FE30D32D6A20288F9112B5C6052CFDB' # print('读取明文+随机{}:{}'.format(len(common.text2list(apdu_text)), apdu_text)) for row in [x for x in range(self.tmn_table.rowCount())\ if self.tmn_table.cellWidget(x, 0).isChecked()]: if tmn_addr and tmn_addr != self.tmn_table.item(row, 1).text(): continue # if logic_addr != -1 and logic_addr != self.tmn_table.cellWidget(row, 2).value(): # continue if chan_index != -1 and chan_index != self.tmn_table.cellWidget(row, 3).currentIndex(): continue compelete_msg = linklayer.add_linkLayer(common.text2list(apdu_text),\ logic_addr=self.tmn_table.cellWidget(row, 2).value(),\ SA_text=self.tmn_table.item(row, 1).text(),\ CA_text=config.COMMU.master_addr, C_text=C_text) config.COMMU.send_msg(compelete_msg, self.tmn_table.cellWidget(row, 3).currentIndex())
def tmn_scan(self): """scan terminal""" wild_apdu = '0501014000020000' compelete_msg = linklayer.add_linkLayer(common.text2list(wild_apdu),\ SA_text='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',\ SA_type=1,\ CA_text=config.COMMU.master_addr,\ C_text='43') config.COMMU.send_msg(compelete_msg, -1)