def open(self): ret, self.deviceID = J2534.ptOpen() ret, self.channel = J2534.ptConnect(self.deviceID, ProtocolID.ISO15765, 0, BaudRate.B500K) if ret == 0: self.dev_status = True maskMsg = J2534.ptMskMsg(16) maskMsg.setID(0xffffffff) patternMsg = J2534.ptPatternMsg(16) patternMsg.setID(SEND_ID) flowcontrolMsg = J2534.ptPatternMsg(16) flowcontrolMsg.setID(RECV_ID) ret, fiterid = J2534.ptStartMsgFilter(self.channel, FilterType.FLOW_CONTROL_FILTER, maskMsg, patternMsg, flowcontrolMsg)
def specific_wait_frame(self, timeout=2): msg = J2534.ptRxMsg() maskMsg = J2534.ptMskMsg(0) maskMsg.setID(0xffffffff) patternMsg = J2534.ptPatternMsg(0) patternMsg.setID(RECV_ID) flowcontrolMsg = J2534.ptPatternMsg(0) flowcontrolMsg.setID(SEND_ID) ret, fiterid = J2534.ptStartMsgFilter(self.channel, FilterType.FLOW_CONTROL_FILTER, maskMsg, patternMsg, flowcontrolMsg) ret = J2534.ptReadMsgs(self.channel, msg, 1, 100) #if ret == 0: # msg.show() ret = J2534.ptReadMsgs(self.channel, msg, 1, 100) if ret == 0: msg.show() return bytes(msg.Data[4:msg.DataSize]) return None
RECV_ID = 0x7e8 try: index = int(sys.argv[1], base=10) except: index = 0 J2534.setDevice(index) ret, id1 = J2534.ptOpen() ret, ch1 = J2534.ptConnect(id1, ProtocolID.ISO15765, 0, BaudRate.B500K) msg = J2534.ptRxMsg() maskMsg = J2534.ptMskMsg(0) maskMsg.setID(0xffffffff) patternMsg = J2534.ptPatternMsg(0) patternMsg.setID(SEND_ID) flowcontrolMsg = J2534.ptPatternMsg(0) flowcontrolMsg.setID(0x641) ret, fiterid = J2534.ptStartMsgFilter(ch1, FilterType.FLOW_CONTROL_FILTER, maskMsg, patternMsg, flowcontrolMsg) start = time.time() while True: if time.time() - start > 10: break
index = int(sys.argv[1], base=10) except: index = 0 J2534.setDevice(index) J2534.setDevice(key=index) ret, id1 = J2534.ptOpen() ret, ch1 = J2534.ptConnect(id1, ProtocolID.ISO15765, 0, 500000) msg = J2534.ptTxMsg(ProtocolID.ISO15765, 32) data = [2, 10, 3, 0, 0, 0, 0, 0, 0] #data = data + [0]*padding(len(data)) msg.setIDandData(0x241, data) maskMsg = J2534.ptMskMsg(16) maskMsg.setID(0xffffffff) patternMsg = J2534.ptPatternMsg(16) patternMsg.setID(0x641) flowcontrolMsg = J2534.ptPatternMsg(16) flowcontrolMsg.setID(0x241) ret, fiterid = J2534.ptStartMsgFilter(ch1, FilterType.FLOW_CONTROL_FILTER, maskMsg, patternMsg, flowcontrolMsg) ret = J2534.ptWtiteMsgs(ch1, msg, 1, 100) time.sleep(3) ret = J2534.ptDisconnect(ch1)