ToB企服应用市场:ToB评测及商务社交产业平台
标题:
CAPL 主动化脚本 - UDS 安全解锁 Lv1
[打印本页]
作者:
九天猎人
时间:
2024-7-22 19:24
标题:
CAPL 主动化脚本 - UDS 安全解锁 Lv1
一种浅显的UDS$27解锁方式,使用capl脚本去实行主动化。
利用CANoe自己的Diagnostic去诊断,返回。
首先:声明2701 2702
拿到种子后,使用diagGenerateKeyFromSeed函数去调用工程里面的DLL文件去计算。
再将计算好的密钥发送到ECU。
void SecurityAccess_Lv1()
{
diagRequest DCM.request Seed_1; // 27 01
diagRequest DCM.request Key_2; // 27 02
const dword Response_time = 50; // diagnostic response time
byte SeedArray[4]; // Actual Seed length
byte KeyArray[4]; // Actual key length
dword KeyActualSize; // Actual key length
int i;
diagSendRequest(Seed_1);// send 27 01 request
if(testWaitForDiagResponse(Seed_1,Response_time)) // Waiting for 2701 response, Waiting for 2701 response, place the seed in array
{
for(i=0;i<elcount(SeedArray);i++)
{
SeedArray[i]=diagGetRespPrimitiveByte(Seed_1,i+2);
// write("%d",SeedArray[i]);
}
}
/* if there is no response within the defined time, consider adding testfail function */
// else
// {
// testStepFail("");
// }
if(0==diagGenerateKeyFromSeed("ecuQualifier",SeedArray,elcount(SeedArray),1,"","",KeyArray,elcount(KeyArray),KeyActualSize))
{
// write("%d, %d, %d, %d",KeyArray[0],KeyArray[1],KeyArray[2],KeyArray[3]);
diagSetParameterRaw(Key_2,"SecurityKey",KeyArray,elcount(KeyArray)); // set 27 02 raw
diagSendRequest(Key_2); // send key to ECU
}
}
复制代码
这种方式简单,可以快速的去操作。
如果想要做一个通用库,不肯定实用。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/)
Powered by Discuz! X3.4