【问题标题】:Can't send Raw Telegram Request through CAPL on CANoe无法通过 CANoe 上的 CAPL 发送原始电报请求
【发布时间】:2021-08-27 18:01:33
【问题描述】:

编辑:主要问题已经解决,但我还有一个问题,请检查第三次尝试。

我正在尝试发送未在我的诊断说明中定义的诊断请求。

我的脚本上有以下内容:

 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;

因为这些函数接收到诊断描述中声明的请求/响应的名称,但是使用这种方法请求的类型是*,那么我该如何使用呢?

【问题讨论】:

  • 你为什么使用一个不存在的diagRequestdiagRequest * Parameter_Req; 有效吗?
  • 让我用使用 diagRequest * Parameter_Req 的结果更新帖子;它工作得更多,但仍然没有完全工作
  • 对不起,我弄错了它现在确实有效,但我仍然有一个问题,如何使用diagGetLastResponse(Parameter_res);on diagResponse Parameter_res 使用相同的方法来声明响应? diagResponse * Parameter_Res;因为这些函数接收到诊断描述上声明的请求/响应的名称,但是使用这个方法请求的类型是*所以我该如何使用呢?

标签: request diagnostics capl canoe uds


【解决方案1】:

您已使用diagGetLastResponse(Parameter_res) 将响应保存到Parameter_res 变量。由于这是使用* 声明的变量,因此您将无法访问诊断说明中指定的参数。
您可以使用函数diagInterpretRespAs 根据您的描述文件将此响应变量转换为合适的类。之后,您可以使用diagGetParameter 获取考虑了分辨率和偏移量的参数。
否则,您可以简单地使用原始响应变量并使用diagGetPrimitiveByte 来访问响应中的字节。

【讨论】:

    猜你喜欢
    • 2012-03-25
    • 2016-12-23
    • 1970-01-01
    • 1970-01-01
    • 2014-10-09
    • 2018-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多