CANoe CAPL结构初始化
问题描述:
我在Vector Canoe CAPL中声明和初始化struct
时遇到了问题。我已经知道来自C/C++的结构,但看起来CAPL中的声明有点不同。CANoe CAPL结构初始化
矢量帮助功能并没有真正揭示。
我有一些CAN ID(例如0x61A)。每个CAN ID是分配不同数量的信号ID(例如0xDDF6)。我想从CAN ID中读出周期性的Signal ID,并计划在一个令人费解的struct
中组织这个。
我已经尝试过不同类型的声明和初始化,但每次遇到解析错误。
你能帮我解决我的问题吗? 不像struct
不像其他想法来组织我的价值观?
谢谢!
答
从CAPL文档:
结构类型可以在CAPL以类似的方式到C声明...
...他们只可以在CAPL程序与版本CANoe的使用7.0服务包3.
实施例:
variables
{
/* declarating a struct */
struct MyData {
int i;
float f;
};
}
on start
{
/* defining a struct variable and initiliazing the elements */
struct MyData data = {
i = 42,
f = 1.32
};
/* accessing the struct elements */
write("i=%d, f=%f", data.i, data.f);
}
输出:
i=42, f=1.320000
答
我有一个缺陷在struct
访问。试图在变量声明例程中初始化struct
参数,而不是在on start
例程中。
工作代码为我的多个数据访问是现在:
variables
{
struct Veh_Database
{
dword ECU;
dword ParamID[8][2];
};
struct Veh_Database ECU_Info[12];
}
on start
{
ECU_Info[0].ECU = 0x1A;
ECU_Info[0].ParamID[0][0] = 0xDD;
ECU_Info[0].ParamID[0][1] = 0xF6;
/* ... */
ECU_Info[1].ECU = 0x12;
ECU_Info[1].ParamID[0][0] = 0xDE;
ECU_Info[1].ParamID[0][1] = 0x9C;
/* ... */
}
感谢您的帮助!
请显示您到目前为止所尝试的内容。 – sergej
什么是错误信息? – sergej