04-28-2025 05:21 AM
In the below CAPL code, the session start request and the seed request are being sent successfully, and we are also receiving a positive response. However, the variable ret
, which should be set to 1 after the request is sent (indicating success), is not getting updated to 1.
Is there anything I need to modify in my code to make sure ret
is correctly updated? -
headers{
}
variables{
}
void MainTest() {
UnlockECU();
}
testcase UnlockSL05() {
diagRequest TCM_0009_00000000_002.Extended_Diagnostic_Session_Start startses;
char buffer[400];
int ret, ret2, ret3;
byte securitySeed[4], securityKey[4];
dword keySizeOut;
diagRequest TCM_0009_00000000_002.Protected_Engineering_Access_Request_Seed_Request seedReq;
diagRequest TCM_0009_00000000_002.Protected_Engineering_Access_Send_Key_Send sendKey;
diagGetObjectName(seedReq, buffer, elCount(buffer));
diagSetTarget("TCM_0009_00000000_002");
diagSendRequest(startses); // Start session
DiagSendRequest(seedReq); // Send seed request
ret = testWaitForDiagRequestSent(seedReq, 50); // Check if request was sent
ret2 = DiagGetLastResponseCode(seedReq);
if (ret == 1) {
diagGetRespParameterRaw(seedReq, "SecuritySeed", securitySeed, elCount(securitySeed));
write("Seed is: 0x%02X%02X%", securitySeed[0], securitySeed[1]);
ret3 = testWaitForGenerateKeyFromSeed("TCM_0009_00000000_002", securitySeed, elCount(securitySeed), 5,
"TCM_0009_00000000_002", "", securityKey, elCount(securityKey), keySizeOut, 5000);
if (ret3 == 1) {
write("Key is: 0x%02X%02X", securityKey[0], securityKey[1]);
diagSetParameterRaw(sendKey, "SecurityKey", securityKey, elCount(securityKey));
diagGetObjectName(sendKey, buffer, elCount(buffer));
DiagSendRequest(sendKey); // Send unlock key
ret = testWaitForDiagRequestSent(sendKey, 2000);
if (ret == 1) {
ret3 = DiagGetLastResponseCode(sendKey);
if (ret3 == -1) {
write("ECU unlocked for level 5");
}
}
}
}
}
04-28-2025 08:00 AM
This doesn't appear to have anything to do with LabVIEW, or any other NI product. You might get the answer you want, but you are more likely to find help in a Vector based discussion forum.
If you are looking to do this through LabVIEW post your code so we can see what it looks like.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord