gpt4 book ai didi

struct - CANoe CAPL结构初始化

转载 作者:行者123 更新时间:2023-12-02 15:18:21 25 4
gpt4 key购买 nike

我在 Vectors CANoe CAPL 中声明和初始化 struct 时遇到问题。我已经知道 C/C++ 中的结构,但 CAPL 中的声明似乎有点不同。

Vector 帮助功能并没有真正揭示。

我有许多 CAN ID(例如 0x61A)。每个 CAN ID 都是分配的不同数量的信号 ID(例如 0xDDF6)。我想从 CAN ID 中循环读取信号 ID,并计划将其组织在一个复杂的 struct 中。

我已经尝试过不同类型的声明和初始化,但每次我都会遇到解析错误。

你能帮我解决我的问题吗?与 struct 不同,还有其他组织我的值(value)观的想法吗?

谢谢和问候!

最佳答案

来自 CAPL 文档:

Structured types can be declared in CAPL in a similar way to C...

... they may only be used in CAPL programs with CANoe from version 7.0 Service Pack 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 - CANoe CAPL结构初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38993352/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com