• 【CANoe/CANalyzer脚本】通过CAPL发送NM帧报文测试网络管理


    优质博文推荐阅读(单击下方链接,即可跳转):

    Vector工具链

    CAN Matrix DBC

    CAN Matrix Arxml

    一、在CANoe/CANalyzer中创建Program Node

    Measurement Setup中,创建Program Node;

    接着导入下面的Demo:NM_Frame.can;(替换需要的CANID,以及数据段的字节值即可

    1. /*@!Encoding:936*/
    2. includes
    3. {
    4. }
    5. variables
    6. {
    7. message 0x211 Message_211 = {dlc=8}; //定义要发送的报文
    8. msTimer Message_211_timer; // 报文发送周期
    9. msTimer Cycle_Start_timer; // 发送窗口:允许报文在该时段发送
    10. msTimer Cycle_End_timer; // 完成一次循环的时间
    11. byte Cycle_Start_timer_Flg = 0;
    12. }
    13. on start
    14. {
    15. setTimer(Message_211_timer,100); // 启动报文周期发送定时器
    16. setTimer(Cycle_Start_timer,10000); // 启动报文发送的窗口定时器
    17. setTimer(Cycle_End_timer,30000); // 启动发送的循环定时器
    18. }
    19. on timer Message_211_timer
    20. {
    21. Message_211.byte(0)=0x00;
    22. Message_211.byte(1)=0x01;
    23. Message_211.byte(2)=0x02;
    24. Message_211.byte(3)=0x03;
    25. Message_211.byte(4)=0x04;
    26. Message_211.byte(5)=0x05;
    27. Message_211.byte(6)=0x06;
    28. Message_211.byte(7)=0x07;
    29. output(Message_211); // 输出报文到CAN总线
    30. if(Cycle_Start_timer_Flg == 0)
    31. {
    32. setTimer(Message_211_timer,100); // 重置报文周期发送定时器
    33. }
    34. }
    35. on timer Cycle_Start_timer
    36. {
    37. if(Cycle_Start_timer_Flg == 0)
    38. {
    39. Cycle_Start_timer_Flg = 1;
    40. }
    41. }
    42. on timer Cycle_End_timer // 完成一个循环后,重置所有定时器
    43. {
    44. Cycle_Start_timer_Flg = 0;
    45. setTimer(Message_211_timer,100);
    46. setTimer(Cycle_Start_timer,10000);
    47. setTimer(Cycle_End_timer,30000);
    48. }

    CANoe/CANalyzer配置完成后的效果如下图:

    二、运行效果

    您会看到NM帧发送10秒,停20秒,如此循环往复。

    END

    获取更多“汽车电子资讯”和“工具链使用”,

    请关注“汽车电子助手”,做您的好助手

  • 相关阅读:
    机器学习笔记:Huber Loss & smooth L1 loss
    一秒出图?SDXL-Turbo实时AI绘画整合包下载
    unocss和tailwindcss css原子引擎
    CodeLite 16.0可以编译通过,但是在编辑器界面会显示找不到标准库头文件
    Linux配置telnet服务端
    慕课9、消息驱动的微服务-Spring Cloud Alibaba RocketMQ
    MySQL优化01-索引
    软件设计模式
    linux中断
    AI/ML如何在山林防火中大显身手
  • 原文地址:https://blog.csdn.net/qfmzhu/article/details/133098501