编辑:主要问题已经解决,但我还有一个问题,请检查第三次尝试查看它。
我正在尝试发送未在我的诊断说明中定义的诊断请求。
我的脚本上有以下内容:
variables
{
//Diagnostic Request that doesn't exist on the .cdd
diagRequest ReadParameter Parameter_Req;
}
on preStart
{
//Sets Diganostic Target just as it was configured
diagSetTarget("DUT");
}
on key 's'
{
//Setting request size to 3 bytes
//I asigned the size to a variable to be able to read which value it had after resizing if but
//everytime I got 0xFF9E or something like that the case is it seems the diagResize is not working
diagResize(Parameter_Req,0x3);
//Setting bytes on the request to creat 22 05 70 (read by identifier)
Parameter_Req.SetPrimitiveByte(0,0x22);
Parameter_Req.SetPrimitiveByte(1,0x05);
Parameter_Req.SetPrimitiveByte(2,0x70);
//Send Request
diagSendRequest(Parameter_Req);
}
但是请求永远不会发送,在 Trace 窗口中没有看到任何新内容。有人知道我做错了什么吗?我尝试使用在诊断描述中声明的诊断请求进行此操作,并且它可以发送请求,因此我知道我的诊断配置正常。此外,CANoe 没有报告错误
谢谢你的帮助
编辑:我也尝试过这种方式
variables
{
byte ReadDID0570[3];
}
on preStart
{
//Sets Diganostic Target just as it was configured
diagSetTarget("DUT");
}
on key 's'
{
//Set bytes and Send Read Request
ReadDID0570[0] = 0x22;
ReadDID0570[1] = 0x05;
ReadDID0570[2] = 0x70;
//Send request
DiagSendRequestPDU(ReadDID0570, elCount(ReadDID0570));
}
但结果相同绝对没有任何反应。
在 M. Spiller 的建议下编辑
variables
{
diagRequest * Parameter_Req;
}
on preStart
{
//Sets Diganostic Target just as it was configured
diagSetTarget("DUT");
}
on key 's'
{
//Resize the request to three bytes
diagResize(Parameter_Req,0x3);
//Set bytes
Parameter_Req.SetPrimitiveByte(0,0x22);
Parameter_Req.SetPrimitiveByte(1,0x05);
Parameter_Req.SetPrimitiveByte(2,0x70);
//Send Request
diagSendRequest(Parameter_Req);
}
这行得通!请求已发送,虽然没有显示在 Trace 窗口中,但我知道它已发送,因为可以在 Trace 上看到响应。现在我唯一的问题是如何使用diagGetLastResponse(Parameter_res);
和on diagResponse Parameter_res
使用相同的方法来声明响应?
diagResponse * Parameter_Res;
因为这些函数接收到诊断描述中声明的请求/响应的名称,但是使用这种方法请求的类型是 * 那么我该如何使用它呢?