- 🍅 我是蚂蚁小兵,专注于车载诊断领域,尤其擅长于对CANoe工具的使用
- 🍅 寻找组织 ,答疑解惑,摸鱼聊天,博客源码,点击加入👉【相亲相爱一家人】
- 🍅 玩转CANoe,博客目录大全,点击跳转👉
CAPL中集成了下面那么多调用vFlash的相关函数,其实实际用到的,可能就三五个函数
使用这些函数接口必须要在测试模块里面加载VFLASHNODELAYER.DLL
Vector官方有Demo可以学习: C:\Users\Public\Documents\Vector\vFlash\8\Examples\vFlash with CANoe\vFlashViaNodeLayer
打开之后,CANoe和Vflash的通道都配置一样(这个工程需要真实总线环境,simulation不行)
"vFlash\Utilities.cin"
中的 TestWaitForvFlashPackReprogrammed
函数就完成了刷写TestWaitForvFlashPackReprogrammed
函数按照下面步骤完成的刷写// 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
}
#include "vFlash\Utilities.cin
",调用 TestWaitForvFlashPackReprogrammed
函数即可。
- 🚩要有最朴素的生活,最遥远的梦想,即使明天天寒地冻,路遥马亡!
- 🚩如果这篇博客对你有帮助,请 “点赞” “评论”“收藏”一键三连 哦!码字不易,大家的支持就是我坚持下去的动力。