admin管理员组文章数量:1532360
2024年5月18日发(作者:)
capl中settimer循环发送和单个发送
CAPL时间类型可以从一张表格清楚表示。
和时间相关用法
on timer my Timer //表示对my Timer设定的时间到反应
Ms Timer my Timer; //声明了一个ms定时器,定时单位是毫秒
timer my Timer; //声明了一个以秒为单位的定时器;
定时器设置:
Set Timer(my Timer,20); //将定时器设置为20ms,并启动my
Timer函数里的动作一次
Set Timer Cyclic(my Timer,1); //设置定时器my Timer为一
个1s为周期的循环定时器;
Cancel Timer(my Timer); //停止定时器my Timer
需要执行该时间时间的函数写法内容:
my Timer
{
tester.d l c =8;
(0) = 0x02;
(1) = 0x10;
(2) = 0x03;
(3) = 0x00;
(4) = 0x00;
(5) = 0x00;
(6) = 0x00;
(7) = 0x00;
output(tester);
}
消息键盘事件
on message 0x7E0 //监测到0x7E0报文的反应
on message UDS Request// 对UDS Request反应
on message CAN1.123 // 对CAN1通道收到报文123的反应
on message * //对所有消息的反应
on message 0x7E0一0x7E8 //对0x7E0一0x7E8 之间报文的反
应
on key‘F’ // 按键盘F时触发动作
on key C tr l一F1 //按Ct r l+F1 触发动作
对于以上两种事件类型是常用到的功能,能满足绝大部分需求。
CAPL中数据类型
无符号
byte (1个字节) word (2个字节) d word(4个字节)
1
有符号
int (2个字节) long (4个字节)
1
浮点型
float double
1
消息的申明
message 0x7E0 i14229_extend;
如果键盘时间出发送报文
on key ‘a’
{
i14229_extend.d l c = 8;//表示长度
i14229_(0) = 0x02; //第0个
i14229_(1) = 0x10;
i14229_(2) = 0x03;
i14229_(3) = 00;
i14229_(4) = 00;
i14229_(5) = 00;
i14229_(6) = 00;
i14229_(7) = 00;
output(i14229_extend); //发送该报文
}
如果接收到则作出反应并发出另一帧
on message 0x7E8
{
//extend session
if(((1) == 0x50) || ((2) == 0x03))
{
i14229_s e ca.d l c = 8;
i14229_s e (0) = 0x02;
i14229_s e (1) = 0x27;
i14229_s e (2) = 0x01;
i14229_s e (3) = 00;
i14229_s e (4) = 00;
i14229_s e (5) = 00;
i14229_s e (6) = 00;
i14229_s e (7) = 00;
output(i14229_s e ca);
}
}
CAPL完整结构通常可由三部分组成。
版权声明:本文标题:capl中settimer循环发送和单个发送 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1716046414a483426.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论