Based on AKKA Beo Box
Restbus Simulation for HMC (implemented with MATLAB Simulink)
PC-Control of Restbus Simulation through XCP over IP
PC-Python-CAN Library for Target-ECU (HMC)
PC-Python-UDS Library for Target-ECU (HMC)
PC-Python-XCP Library for target-ECU (HMC)
All services listed above are integrated into ECU-TEST (TraceTronic GmbH https://www.tracetronic.com/products/ecu-test/)
Integration (EAGLE)
Verification & Software Development
ECU-TEST 8 Application:
UDS
XCP to HMC
XCP to BEO CANF-FD
Send CAN-Frame
Receive CAN-Frame
UDS_REQUEST_ID = 0x0740
UDS_RESPONSE_ID = 0x0748
#create UDS instance
self.UDS = uds.createUdsConnection("HMC.odx", "HMC", reqId=UDS_REQUEST_ID, resId=UDS_RESPONSE_ID,
transportProtocol="CAN", interfaceName="Beo")
# switch to programming session
self.UDS.diagnosticSessionControl("Programming Session")
# get seed
seed = self.UDS.securityAccess("Seed Level MPT")
#calculate key
key = compute_key( SA_DEFINITIONS[SA_TYPES.MPT][SA_TYPE.ID], seed)
#send calculated key
self.UDS.securityAccess("Key Level MPT", key = key)
XCP_MASTER_ID = 0x0661
XCP_SLAVE_ID = 0x0660
#create XCP instance for HMC
hmc = Xcp('can', config={'CAN_ID_MASTER': XCP_MASTER_ID, \
'CAN_ID_SLAVE': XCP_SLAVE_ID, 'CAN_DRIVER': "BeoXcpInterface", \
'CREATE_DAQ_TIMESTAMPS': True})
#create XCP instance for Beo
beo = Xcp('eth', config={'HOST': "192.168.131.18", 'PORT': 5555, 'CREATE_DAQ_TIMESTAMPS': True})
#DAQ
hmc.addDaqEntry("daq0entry0", OdtDataset(addr=0x7000388E, typ=Xcp.getDataType("UWORD")), 4)
hmc.addDaqEntry("daq0entry1", OdtDataset(addr=0x7000286C, typ=Xcp.getDataType("WORD")), 4)
hmc.addDaqEntry("daq1entry0", OdtDataset(addr=0x700146FC, typ=Xcp.getDataType("ULONG")), 4)
hmc.addDaqEntry("daq1entry1", OdtDataset(addr=0x700146F8, typ=Xcp.getDataType("LONG")), 4)
#START
hmc.start()
cnt = 0
try:
while 1:
time.sleep(0.5)
buf = np.uint16(cnt).tobytes()
hmc.write(0x7000388E, buf)
beo.write(0xfeddc71c, buf)
cnt = cnt + 1
print("HMC:")
print("daq0entry0:\t{0}".format(hmc.getDaqEntry("daq0entry0").value)) # counter
print("daq0entry1:\t{0}".format(hmc.getDaqEntry("daq0entry1").value))
print("daq1entry0:\t{0}".format(hmc.getDaqEntry("daq1entry0").value))
print("daq1entry1:\t{0}".format(hmc.getDaqEntry("daq1entry1").value))
print("Beo:")
print("u8:\t{0}".format(beo.getDaqEntry("u8").value))
print("u16:\t{0}".format(beo.getDaqEntry("u16").value)) # counter
print("u32:\t{0}".format(beo.getDaqEntry("u32").value))
print("i8:\t{0}".format(beo.getDaqEntry("i8").value))
print("")
RBS läuft auf BEO
PDUs können über XCP geändert werden
CAN_MSG3_PDU= 3
New_content= np.uint16(CAN_MSG3_PDU).tobytes()
#PDU memory location absolute address
(in Simulink Model ) is 0x7000388E
#write new content
hmc.write(0x7000388E, New_content)
#Beo sends automatically new value to the CAN-FD bus
ECU Reset:
self.uds_inst.send([0x11,0x01])
Switch Session:
self.uds_inst.diagnosticSessionControl("Development Session")
Send Key:
seed = self.mem_get(u"security_seed");
#print("seed " + seed)
key = compute_key( SA_DEFINITIONS[SA_TYPES.MPT][SA_TYPE.ID], seed)
#print("key " + key)
self.uds_inst.securityAccess("Key Level MPT", key = key)