variables
{
//actual size of Seed and Key Arrays depend on ECU
byte gSeedArray[2];
int gSeedArraySize = 1;
int gSecurityLevel = 0x02;
char gVariant[200] = "Variant1";
char gOption[200] = "option";
byte gKeyArray[255];
int gMaxKeyArraySize = 255;
dword gActualSizeOut = 0;
char gDebugBuffer[2000];
diagRequest ECU.SeedLevel_0x01_Request gSeedReq;
diagResponse ECU.SeedLevel_0x01_Request gSeedResp;
diagRequest ECU.KeyLevel_0x01_Send gKeyReq;
}
//Unlock ECU by calling customer specific SeedKey DLL (e.g. in a CAPL test module)
testcase UnlockEcu()
{
long ret;
//Request seed from ECU
diagSendRequest(gSeedReq);
//Wait until request has been sent completely
testWaitForDiagRequestSent(gSeedReq, 1000);
//Wait for response and write seed from response parameter to array
testWaitForDiagResponse(gSeedReq, 1000);
diagGetLastResponse (gSeedReq, gSeedResp);
diagGetParameterRaw (gSeedResp, "SecuritySeed", gSeedArray, elcount(gSeedArray));
//Calculate key
ret = diagGenerateKeyFromSeed ("ECU", gSeedArray, gSeedArraySize, gSecurityLevel, gVariant, gOption, gKeyArray, gMaxKeyArraySize, gActualSizeOut);
if( 0 == ret) //diagGenerateKeyFromSeed successful
{
//Write result to diagnostic request
diagSetParameterRaw(gKeyReq, "SecurityKey", gKeyArray, gActualSizeOut);
//Send Key to unlock ECU
gKeyReq.SendRequest();
testWaitForDiagRequestSent(gKeyReq, 1000);
}
}
void MainTest ()
{
UnlockEcu();
}