How to use CANiogen with the CANIf module of the RBS Configurator?
Frage
I have a complex rest bus simulation (RBS) still implemented with CANiogen while I have others set up by the RBS Configurator: How should I proceed to interface the CANiogen based RBS with the CAN hardware?
Antwort
With CM 8.1 a CAN interface (CANIf) module was introduced in order to fully automate the set up of a CAN rest bus simulation using the GUI. Previously, users had to edit their src/IO.c particularly in IO_Init() in order to initialize and configure a CAN module (M51 or M410).
In some complex projects, CANiogen based RBS are deployed together with those of the RBS Configurator. In this case the CAN module is configured by the CANIf module of the RBS Configurator. The following steps will describe how CANiogen can access this CANIf so that its CAN configuration does not collide with that of the RBS Configurator.
When working with an implementation based on Examples\IO_CAN\src.IO_CAN-xeno, the IO.c in your CarMaker project (to avoid to edit template files) will be edited this way:
The following sections for identifying the last slot with a CAN module and the initializing such a module on this slot must be removed:
The following section, which is also used to initialize the CANiogen module, can be used to open a CAN interface by simply specifying its name and adding a function to be called when this CAN interface will receive data:
Depending on the used CM version it is necessary to include the header can_interface.h from IO.c to avoid some warnings during compilation.
The passed callback still must be implemented. It consists of a function that wraps the relevant CANiogen function:
Since the received CAN messages are now processed by the callback function, the while loop and its entire content can be removed from the IO_In function.
In addition, the header IOVec.h must be edited
- to extend its structure to another member, which is used to identify the opened CAN interface
- and to let know that the wrapper send function is available:
Please also note the inclusion of the header Periodic.h in order to avoid an error related to tCPeriodic while compiling IO_CAN.c in the next step. Once done, edit the IO_CAN.c file
- in order to include IOVec.h
- and to set the corresponding function pointer on the wrapper send function:
After that, you only have to edit the CANIfParamters infofile set in Data/Config/ECUParameters to define and configure an interface that has the name of the variable IfName. From CarMaker 11, you can use the GUI of the IO Configurator to activate the corresponding channel and to set it up as you'll need. In older versions, you can do this, for example, by editing the Data/Config/CANIfParameters in a text editor.
Details about the keys of the info files can be found in the Programmer's Guide in chapter "CAN Interface API".
Your compiled CarMaker application now only has to be started with the command line options -io can,democan.
- Datum: 24.05.2023
- Produkt: CarMaker/HIL
- Version: 11.0
- Komponente: CANiogen
- Sprache: Englisch
Tags
CANiogenCAN
RBS
IO