概述
CANoe/CANalyzer C library 简称CCL,允许用户使用C语言开发应用程序(dll),应用程序可以在CANoe/CANalyzer工程中运行。
CCL提供如下类似CAPL的功能:
- 收发CAN、LIN报文
- 定时器服务
- 访问系统变量
如何创建一个CANoe/CANalyzer C library
- Create a new Win32 project for Visual C++ with the Project Wizard of Visual Studio and select the application type DLL when doing so.
- Copy the directory CCL together with the six files it contains (CCL.h, CCL.cpp, CCL.def, VIA.h, VIA_CAN.h and VIA_LIN.h) to the project directory of the newly created Visual Studio project. The CCL directory is located in Programming/C_Library when the CANoe/CANalyzer sample configurations are installed.
- Add the file CCL.cpp to your Visual Studio project and deactivate the use of the Precompiled Header for this file in the compiler settings of Visual Studio.
- If the Project Wizard created a source file with the DLLMain function, delete this function. Implementation of the function is already provided by the framework.
- Enter the CCL.def file in the linker settings of Visual Studio for the Module Definition File.
- If you add your own C file to the project, include the file CCL.h and implement the function cclOnDllLoad.
- Compile and link your project to receive your C library as a Windows DLL.
实际开发应用中我们可以基于CANoe提供的demo为base进行开发,从而省去上述创建过程。
CCL demo 一般在如下路径:
C:\Users\Public\Documents\Vector\CANoe\Sample Configurations 13.0.155\Programming\C_Library\Examples
CCL demo
双击CANoeCCL.sln打开例程:
例程包括CAN、LIN、Timer、SystemVariables等API的demo工程
CANoeCCL.sln
CCL API的详细描述请参考CCL.h文件和CANoe Help 文档
如何加载生成的动态链接库
在CANoe工程中依次点击:
File -> Options -> Programming -> C Libraries -> Add
点击Add后在弹出的对话框中添加生成的dll
添加dll
点击CANoe工程Start按钮后dll会自动开始运行