capl使用汇总

数组类

2维数组定义

dword data[DIDN][100];

其中数组的类型是dword,二维数组的元素个数是DIDN值,第二维100表示每个数组data[i]的都是一个一维数组并且这个一维数组是100个dword数组成的

结构体

结构体定义

以下的结构体类型supDTC(支持的DTC)中包含了一个dword数组类型

const int DTCN = 10;
struct supDTC { dword DTCnumber[DTCN];};
struct supDTC SupDtclist=
{
{0xC00188, 0xC00288, 0xC00388, 0xC00488, 0xC00588, 0xC00688, 0xC00788, 0xC00888, 0xF00616, 0xF00617}
}; 

以下的结构体SupDtclist赋初始值的时候要按照结构体类型supDTC中的成员类型赋值

const int DIDN=7;
struct supDID
{
  dword didNumber[DIDN];
  dword didLength[DIDN];
  int bootreadflag[DIDN];
  int bootwritflag[DIDN];
  int appwriteflag[DIDN];// 1是支持,0是不支持?

  };
  struct supDID supdidlist = 
  {
    {//DID
      0xF187, 0xF18A, 0xF190,    0xF193,    0xF195, 0xF19D,0xF1A1    },
    {//Data length
      24,16,17,8,8,4,16    },
    {//bootreadflag
      0,0,0,0,0,0,0},
    {//bootwriteflag
      0,0,0,0,0,0,0},
    {//appwriteflag:DID writable
      0,0,1,0,0,1,1}
  };

同理结构体类型supDID中包含了多个数组类型,在定义其类型的结构体supdidlist的时候,初始值赋值顺序就是结构体类型中的元素顺序

测试报告接口

TestInfoTable

long table = 0;
table = TestInfoTable("测试步骤");
TestInfoHeadingBegin(table, 0);
TestInfoCell(table, "step");
TestInfoCell(table, "description");
TestInfoRow(table, 0);
TestInfoCell(table, "1");
TestInfoCell(table, "测试工具发送 ECU 支持的请求报文(该请求正确接收后,ECU 发送多帧响应报文)");
TestInfoRow(table, 0);
TestInfoCell(table, "1");
TestInfoCell(table, "测试工具发送 ECU 支持的请求报文(该请求正确接收后,ECU 发送多帧响应报文)");
TestInfoRow(table, 0);
TestInfoCell(table, "1");
TestInfoCell(table, "测试工具发送 ECU 支持的请求报文(该请求正确接收后,ECU 发送多帧响应报文)");
TestStep(0, "", table);

输出样式:

UDSonCANTest0001.html

capl使用汇总_第1张图片

testCaseDescription

testCaseDescription("验证 ECU 在多帧报文发送过程中,正确处理流控制帧未收到的情况");
testCaseDescription("\n1) 测试工具发送 ECU 支持的请求报文(该请求正确接收后,ECU 发送多帧响应报文)");
testCaseDescription("\n2) 测试工具接收到 ECU 发送的肯定响应报文第一帧 FF 后,启动一计时器,当计时器达到N_Bs+100ms 后发送流控制帧");
testCaseDescription("\n3) 验证 ECU 不再发送后续连续帧");

输出样式:

testRepot.html

capl使用汇总_第2张图片

CAN报文测试

周期检查

涉及5个函数:

//aCallback in simulation nodes this parameter has to be set, in test modules this parameter is optional
dword ChkStart_MsgRelCycleTimeViolation (Message aObservedMessage, double aMinRelCycleTime, double aMaxRelCycleTime, Callback aCallback);

保留位填充值检查

void checkmsgreservedbitschk(char msgName[], dword can_id, int can_type, int test_duration)
{
  long chk_id;
  switch(can_type)
  {
    case 1:
    {
      chk_id=ChkStart_PayloadGapsObservation(can_id,1);//J1939节点报文,填充1
      break;
    }
    default:
    {
      chk_id=ChkStart_PayloadGapsObservation(can_id,0);//标准帧节点报文和诊断报文,填充0
      break;
    }
  }
  testAddCondition(chk_id);
  testWaitForTimeout(test_duration);
  testRemoveCondition(chk_id);
  ChkControl_Stop(chk_id);
  if(ChkQuery_NumEvents(chk_id)==0)
    testStepPass("chk","message %s filled correct value in reserved bits",msgName);
  else
    testStepFail("chk","message %s filled wrong value in reserved bits",msgName);
}

报文属性

RTR远程帧

Simmsg.RTR=1;

test module

IL层控制

ILNodeControlResume

开启某个节点的报文发送

ILNodeControlResume("GW");

如果simulation的node节点已经被capl限制IL层自动发送报文,如用ILControlInit()、ILControlWait()等,那么在test module里要触发IL层的某个报文发送,必须先开启这个报文所在的node节点的IL层:ILNodeControlResume,之后才能使用ILNodeControlMsg开启报文,否则直接使用ILNodeControlMsg就会不起作用,没有报文出来

ILNodeControlMsg

开启发送报文

ILNodeControlMsg(BCM1, 1, 2, 0, 0);

停止发送报文

ILNodeControlMsg(BCM1, 2, 0, 0, 0);

指定待测bus

setBusContext

setBusContext(GetBusNameContext("ADU"));

setBusContext(GetBusNameContext(“xxx”));中xxx是simulation setup窗口中network的名字

capl使用汇总_第3张图片

event使用

testSupplyTextEvent

发送test类型的event,要和TestWaitForTextEvent成对使用

testSupplyTextEvent("ErrorFrame occurred!");
//do something
TestWaitForTextEvent("ErrorFrame occurred!",2000);

TestJoinTextEvent

加入等待事件,与TestWaitForAnyJoinedEvent成对使用

// waits for a specified text event
long result;
dword index = 0;
result = TestJoinTextEvent("ErrorFrame occurred!");
// ... other join events
TestJoinEnvVarEvent(MyEnvVar);
TestJoinSignalInRange(Velocity, 80, 100);

index = TestWaitForAnyJoinedEvent(2000);

// on ErrorFrame handler
on errorFrame
{
   TestSupplyTextEvent("ErrorFrame occurred!");
}

打印write

writeEx

capl write信息打印在trace窗口

writeEx(-3,2,"产生欠压");

函数解释:

capl使用汇总_第4张图片

trace窗口显示:

capl使用汇总_第5张图片

你可能感兴趣的:(CANoe,capl,capl,canoe,测试脚本)