当前位置: 首页 > news >正文

CANoe中使用CAPL函数接口调用Vflash文件

  • 🍅 我是蚂蚁小兵,专注于车载诊断领域,尤其擅长于对CANoe工具的使用
  • 🍅 寻找组织 ,答疑解惑,摸鱼聊天,博客源码,点击加入👉【相亲相爱一家人】
  • 🍅 玩转CANoe,博客目录大全,点击跳转👉

在这里插入图片描述

  • CAPL中集成了下面那么多调用vFlash的相关函数,其实实际用到的,可能就三五个函数

  • 使用这些函数接口必须要在测试模块里面加载VFLASHNODELAYER.DLL
    在这里插入图片描述

  • Vector官方有Demo可以学习: C:\Users\Public\Documents\Vector\vFlash\8\Examples\vFlash with CANoe\vFlashViaNodeLayer

  • 打开之后,CANoe和Vflash的通道都配置一样(这个工程需要真实总线环境,simulation不行)

在这里插入图片描述

  • 直接运行测试用例,可以看到Trace有数据,测试pass

在这里插入图片描述

  • 为什么即使没接真实的件,他也能有报文和刷写呢?因为simulation中它模拟节点做了应答
    在这里插入图片描述
  • Demo中的测试用例呢,就调用了"vFlash\Utilities.cin"中的 TestWaitForvFlashPackReprogrammed函数就完成了刷写

在这里插入图片描述

  • 再看下TestWaitForvFlashPackReprogrammed函数按照下面步骤完成的刷写
  • TestWaitForvFlashInitialized:初始化vFlash
  • TestWaitForvFlashProjectLoaded :加载.vflashPack工程
  • TestWaitForvFlashProjectLoaded :开始刷写
  • TestWaitForvFlashProjectUnloaded:卸载工程文件
  • TestWaitForvFlashDeinitialized:xxx
// Performs all necessary steps to reprogram the passed vFlashPack
// This function will wait until reprogramming has completed (it cannot be used in a simulation node)
enum vFlashStatusCode TestWaitForvFlashPackReprogrammed(char flashpack[])
{
// Test functions are only available in test modules!
#if TEST_NODEenum vFlashStatusCode lastStatusCode;enum vFlashStatusCode resultCode;char errorText[gkMaxErrorTextLength];int hasProjectLoaded = 1;if (!ProcessPathName(flashpack)) {snprintf(errorText, gkMaxErrorTextLength, "FATAL ERROR: No path to flashpack given!");write(errorText);   TestStepFail("TestWaitForvFlashInitialized", errorText);return FR_FileNotFound; }//----- Initialize vFlash Library -----lastStatusCode = resultCode = (enum vFlashStatusCode) TestWaitForvFlashInitialized();if (lastStatusCode != Success){TestWaitForvFlashLastErrorMessage(errorText, 1024);snprintf(errorText, gkMaxErrorTextLength, "vFlash initialization error: %s", errorText);write(errorText);TestStepFail("TestWaitForvFlashInitialized", errorText);return resultCode;}else{TestStepPass("TestWaitForvFlashInitialized", "vFlash initialized successfully");}// from here on, return statements are not possible, because we have to call the "teardown" methods as well!// ==> how much complicated want we to be...//----- Load Project ----lastStatusCode = resultCode = (enum vFlashStatusCode) TestWaitForvFlashProjectLoaded(_gFlashpack);if (lastStatusCode != Success){hasProjectLoaded = 0;TestWaitForvFlashLastErrorMessage(errorText, 1024);snprintf(errorText, gkMaxErrorTextLength, "vFlash load project error: %s", errorText);write(errorText);TestStepFail("TestWaitForvFlashProjectLoaded", errorText);}else{TestStepPass("TestWaitForvFlashProjectLoaded", "Successfully loaded project: %s", _gFlashpack);}//----- Activate Network// Activation of this function call is only required in case of flashing a FlexRay ECU // and vFlash has to do Network Managementif (lastStatusCode == Success){lastStatusCode = resultCode = (enum vFlashStatusCode) TestWaitForvFlashNetworkActivated();if (lastStatusCode != Success){TestWaitForvFlashLastErrorMessage(errorText, 1024);snprintf(errorText, gkMaxErrorTextLength, "vFlash activate network error: %s", errorText);TestStepFail("TestWaitForvFlashNetworkActivated", errorText);write(errorText);}else{TestStepPass("TestWaitForvFlashNetworkActivated", "Network activated successfully");}}//----- Start Reprogramming ----if (lastStatusCode == Success){lastStatusCode = resultCode = (enum vFlashStatusCode) TestWaitForvFlashReprogrammed();if (lastStatusCode != Success){TestWaitForvFlashLastErrorMessage(errorText, 1024);snprintf(errorText, gkMaxErrorTextLength, "vFlash reprogramming error: %s", errorText);TestStepFail("TestWaitForvFlashReprogrammed", errorText);write(errorText);}else{TestStepPass("TestWaitForvFlashReprogrammed", "ECU reprogrammed successful");}}//----- Unload Project ----if (hasProjectLoaded){lastStatusCode = (enum vFlashStatusCode) TestWaitForvFlashProjectUnloaded();if (lastStatusCode != Success){    TestWaitForvFlashLastErrorMessage(errorText, 1024);snprintf(errorText, gkMaxErrorTextLength, "vFlash unload project error: %s", errorText);TestStepFail("TestWaitForvFlashProjectUnloaded", errorText);write(errorText);}else{TestStepPass("TestWaitForvFlashProjectUnloaded", "Project unloaded successfully");}   }//----- Deinitialize vFlash Library ----lastStatusCode = (enum vFlashStatusCode) TestWaitForvFlashDeinitialized();if (lastStatusCode != Success){TestWaitForvFlashLastErrorMessage(errorText, 1024);snprintf(errorText, gkMaxErrorTextLength, "vFlash deinitialization error: %s", errorText);TestStepFail("TestWaitForvFlashDeinitialized", errorText);write(errorText);}else{TestStepPass("TestWaitForvFlashDeinitialized", "vFlash deinitialized successfully");}return resultCode; // last result is of TestWaitForvFlashReprogrammed; result of Unload/Deinitialize ignored
#else // simulation nodewrite( "ERROR: the function TestWaitForvFlashPackReprogrammed is only available in a test module!");return TestFunctionInSimulationCalled;
#endif // TEST_NODE
}
  • 如果想要刷写自己的vFlash文件,简单的话就是把 gFlashpack给个自己文件的路径即可;想要集成在自己工程中用的话,要引用 #include "vFlash\Utilities.cin",调用 TestWaitForvFlashPackReprogrammed函数即可。

  • 自己调用的时候,别忘了要在测试模块中加载下面的DLL
    在这里插入图片描述

在这里插入图片描述

🌎总结

23

7

  • 🚩要有最朴素的生活,最遥远的梦想,即使明天天寒地冻,路遥马亡!

  • 🚩如果这篇博客对你有帮助,请 “点赞” “评论”“收藏”一键三连 哦!码字不易,大家的支持就是我坚持下去的动力。
    18
http://www.lryc.cn/news/39738.html

相关文章:

  • 三天吃透计算机网络面试八股文
  • shp数据添加wkt字段并导出成csv,leaflet绘制使用
  • Java——二叉树的最近公共祖先及二叉搜索树介绍
  • Stable Diffusion加chilloutmixni真人图片生成模型,AI绘图杀疯了
  • Matplotlib 绘图实用大全
  • MyBatis源码用了哪些设计模式?
  • 【16.整数转罗马数字】
  • 前端小技巧
  • Servlet2.0
  • 【c++】继承
  • minio安装配置和使用(二)客户端安装
  • 【如何使用Arduino设置GRBL和控制CNC机床】
  • 项目测试——博客系统
  • 【C习题】经典数组与指针面试题(万字)
  • 【ArcGIS Pro二次开发】(13):ProWindow的用法
  • HTML/CSS/JS 基本语法
  • 对于从事芯片行业的人来说,有哪些知识是需要储备的?
  • 测试场景设计
  • 《重构》增强代码可读性
  • 数据分析自学路线
  • 蓝桥杯C++组怒刷50道真题
  • 【期末小作业】HTML、CSS前端静态网页
  • Windows逆向安全(一)之基础知识(二)
  • Python 基础教程【2】:条件语句和循环语句
  • 【React避坑指南】useEffect 依赖引用类型
  • Android binder通信实现进程间通信
  • 2023年BeijngCrypt勒索病毒家族最新变种之.halo勒索病毒
  • 【LeetCode】BM1 反转链表、NC21 链表内指定区间反转
  • 拼多多24届暑期实习真题
  • JS高级知识总结