编辑:主要问题已解决,但我还有一个问题,请检查第三次尝试以查看它。
我正在尝试发送未在我的诊断说明中定义的诊断请求。
我的脚本中有以下内容:
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);
}
但是请求从未发送,在跟踪窗口中没有看到任何新内容。有谁知道我做错了什么?我使用在诊断说明中声明的诊断请求进行了尝试,并且可以发送请求,因此我知道我的诊断配置没问题。另外,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;
因为这些函数接收在诊断描述中声明的请求/响应的名称,但是使用这种方法请求的类型是 * 那么我该如何使用它?
答案 0 :(得分:0)
您已使用 diagGetLastResponse(Parameter_res)
将响应保存到 Parameter_res
变量。由于这是使用 *
声明的变量,因此您将无法访问诊断说明中指定的参数。
您可以使用函数 diagInterpretRespAs
根据您的描述文件将此响应变量转换为合适的类。在此之后,您可以使用 diagGetParameter
获取考虑了分辨率和偏移量的参数。
否则,您可以简单地使用原始响应变量并使用 diagGetPrimitiveByte
访问响应中的字节。