def openTPChannel(self, device='can0'): """ Open a TP channel to DeviceUnderTest """ try: bcm = llcf.SOCKET("PF_CAN", "SOCK_DGRAM", "CAN_BCM") bcm.setblock(1) self.setTPFilter(bcm, device) self.setTPStartup(bcm, device) #Get Tx and Rx ID for TP channel res = bcm.read() finally: bcm.close() # if response is not empty tp = None if res is not -1: if res[0] == self.bcmSup.TX_EXPIRED: print "Received TX_EXPIRED" elif res[0] == self.bcmSup.RX_CHANGED: print "Received RX_CHANGED" tp = llcf.SOCKET("PF_CAN", "SOCK_SEQPACKET", "CAN_TP20") tp.setblock(0) try: help = llcf_helper.LLCFMsg() txrx = help.getTxRx(res) #print "TxRx tuple for CS = 0x%X,0x%X" % (txrx[0],txrx[1]) tp.connect(device, txrx) except: print "Got exception during TP startup" tp.close() raise else: print "Unknown response. Check script." return tp
print('llcf reload unssucces') import llcf except: print " llcf not found at all " try: reload(time) except: try: print('time reload unssucces') import time except: print " llcf not found at all " try: a = llcf.SOCKET() except: #a.listen() #newid = a.accept() ## Upon successful completion, accept() returns a nonnegative integer which is a descriptor for the accepted socket. #readbuf = a.read(newid[2]) # the accept returns the file descriptor of the new socket. #print readbuf #newstring = readbuf + 'with love from server' #a.write(newid[2], newstring,'can0') #time.sleep(1) print 'exception reached' a.close() # try: # a.bind() # print "binding" # except:
msg_head.iVal2Sec = 0 msg_head.iVal2USec = 0 # Configure frame tuple frame = llcf_helper.LLCFFrame() frame.canId = 0x200 + LOCAL_TP_ID frame.canDlc = 7 frame.data = [ REMOTE_TP_ID, 0xC0, 0x00, 0x10, (LOCAL_TP_RX_ID & 0xFF), (LOCAL_TP_RX_ID >> 8 & 0x07), APPLICATION_PROTO ] print "Header = ", msg_head.getMsgHead() print "Frame = ", frame.getFrame() #Create BCM socket and start TP Dynamic Channel Setup bcm = llcf.SOCKET("PF_CAN", "SOCK_DGRAM", "CAN_BCM") bcm.setblock(1) try: res = bcm.startupTP20(tuple(msg_head.getMsgHead()), tuple(frame.getFrame()), "can0") #time.sleep(0.015) res2 = bcm.read() finally: bcm.close() print "written character = ", res print "read character = ", res2 if res2 == 0: print "No TX or RX id received" else: tx_id = 0x4EC #res[0]
import llcf except: print " llcf not found at all " try: reload(time) except: try: print('time reload unssucces') import time except: print " llcf not found at all " # raw = llcf.SOCKET("PF_CAN", "SOCK_RAW", "CAN_RAW") # frame = llcf.FRAME(0x200, (0x54, 0xc0, 0x00, 0x10, 0x00, 0x03, 0x01 )) # raw.send(frame, "can0") raw = llcf.SOCKET("PF_CAN", "SOCK_RAW", "CAN_RAW") frame = llcf.FRAME(0x200, (0x54, 0xc0, 0x00, 0x10, 0x00, 0x03, 0x01)) raw.send(frame, "can0") time.sleep(0.015) raw.close() a = llcf.SOCKET() p = llcf.PAYLOAD() try: a.connect("can0", (0x4ec, 0x300)) except: a.close else: a.write1(p, "can0") print "closing"
print('llcf reload unssucces') import llcf except: print " llcf not found at all " try: reload(time) except: try: print('time reload unssucces') import time except: print " time not found at all " file1 = open('LogFiles/dump.txt', 'w') socket = llcf.SOCKET() try: while 1: messagesonbus = socket.show() if (messagesonbus > 0): dlc2 = len(messagesonbus[3]) b = [] y = [] y = list(messagesonbus) y[0] = hex(messagesonbus[0])[2:] y[3] = (map(hex, messagesonbus[3])) y[3] = [element[2:] for element in y[3]] total = y for num in range(0, 4): b.append(str(total[num])) file1.write(b[num])
if __name__ == "__main__": dut01 = dut_helper.dutObj() dut02 = dut_helper.dutObj() dut03 = dut_helper.dutObj() dut01.setRemoteTpId(0x54) dut02.setRemoteTpId(0x53) dut03.setRemoteTpId(0x55) duts = [dut01, dut02, dut03] tp = None bcm = None try: #Create BCM socket for TP Dynamic Channel Setup and cyclic ignition message bcm = llcf.SOCKET("PF_CAN", "SOCK_DGRAM", "CAN_BCM") kl15 = bcm_helper.bcm_helper() kl15.startKl15(bcm, 'can0') while 1: try: for dut in duts: tptest = tp20_helper.tp20_helper(dut) time.sleep(5) tp = tptest.openTPChannel('can0') if tp is not None: kwp = kwp2000.kwp2000() getMWB01(llcf, tp, kwp) getMWB05(llcf, tp, kwp) getMWB06(llcf, tp, kwp) getMWB07(llcf, tp, kwp)