I have some issues regarding the security access to an ecu.
In generell everything seems to work fine until I have to send the key -16 bytes of data-.
I use PCAN-View to monitor the communication and I realized, that the message-flow starts correctly.
The application sends the first frame and the ECU responds with a FC frame, but that's all. The function UDS_WaitForService returns PUDSStatus = 0x7 NO_MSG.
I use non standard CAN IDs, which I have mapped accordingly to example 4.3.3.
I tested the mappings with the function SvcReadDataByIdentifier (received multiple frames with correct tester fc frame) and UDS_WaitForService returns the correct data.
I'll try to explain my source code with some kind of pseudo code.
Code: Select all
TPUDSStatus result;
TPUDSCANCHandle uds_channel = 0x51; //USBBUS1
TPUDSMsg MSG;
MSG.NETADDRINFO.SA = 0xF1;
MSG.NETADDRINFO.TA = 0x01;
MSG.NETADDRINFO.RA = 0x00;
MSG.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
MSG.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Note: Channel is properly initialized with UDS_Initialize(..)
// set custom Can ID tester ->ecu
MSG.DATA.RAW[0] = 0;
MSG.DATA.RAW[1] = 0;
MSG.DATA.RAW[2] = 0x02;
MSG.DATA.RAW[3] = 0x34;
MSG.DATA.RAW[4] = 0;
MSG.DATA.RAW[5] = 0;
MSG.DATA.RAW[6] = 0x06;
MSG.DATA.RAW[7] = 0x78;
result = UDS_SetValue(uds_channel, PUDS_PARAM_MAPPING_ADD, &MSG, sizeof(MSG));
// add custom Can ID ecu -> tester
MSG.NETADDRINFO.SA = 0x01;
MSG.NETADDRINFO.TA = 0xF1;
MSG.DATA.RAW[0] = 0;
MSG.DATA.RAW[1] = 0;
MSG.DATA.RAW[2] = 0x06;
MSG.DATA.RAW[3] = 0x78;
MSG.DATA.RAW[4] = 0;
MSG.DATA.RAW[5] = 0;
MSG.DATA.RAW[6] = 02;
MSG.DATA.RAW[7] = 34;
result = UDS_SetValue(uds_channel, PUDS_PARAM_MAPPING_ADD, &MSG, sizeof(MSG));
MSG.NETADDRINFO.SA = 0xF1;
MSG.NETADDRINFO.TA = 0x01;
// use MSG.NETADDRINFO with a new TPUDSMsg
TPUDSMsg Testmsg;
Testmsg.NETADDRINFO = MSG.NETADDRINFO;
//succeeds every time
//read bytes e.g. ECU first frame -> tester flow control -> ECU cons. frames
result = UDS_SvcReadDataByIdentifer(uds_channel, Testmsg ,0x2494, 2);
//change session to extended
//CAN tracing showed that tester present is sent periodically.
result = UDS_SvcDiagnosticSessionControl(uds_channel, Testmsg, 0x03);
// This request succeeds.
// I am able to receive 16 bytes
result = UDS_SvcSecurityAccess(uds_channel, Testmsg, PUDS_SVC_PARAM_SA_RSD_3, null, 0);
// magical things done with seed. [...]
// further called Buffer[16]
TPUDSMsg request ;
result = UDS_SvcSecurityAccess(uds_channel,Testmsg,PUDS_SVCPARAM_SK_4, Buffer, sizeof(Buffer))
if(result == PUDS_ERROR_OK)
{
// this function returns "NO MESSAGE" in this particular case
//the CAN trace shows that the first frame was correct
//0x234 :: 10 12 27 xx xx xx xx xx <- tester XX XX -> correct first bytes of Buffer[16]
//0x677 :: 30 08 0A 01 xx xx xx xx <- ecu
// no furhter tester communciation
//expected communication
//0x234 :: 21 .... <- tester missing bytes till all bytes are transmitted
//0x234 :: 22 ....
//0x677 :: 02 67 ... <- ecu
// function return happens pritty fast, way less than 10 seconds.
result = UDS_WaitForService(uds_channel, &Testmsg, &request, null);
};
I have no issues receiving many ISO TP frames.
Do I use the wrong function in this case?
Tester hast to send multiple messages and has to react to a FC frame correclty?
Does the DiagnosticSessionControl function change the overall behavior and do i have to do some kind of remapping, after changing the session?
Maybe you can help me in this case, if I'm missing some infos regarding the uds.dll.
Thank you very much.