The interpreter module for DBC format is initialized as follows:
The DBC message and signals definition file will be parsed to initialize the interpreter. Please refer to a DBC file format documentation for additional details on the expected syntax.
An interpreter for user-defined format is initialized as follows:
The dwCANInterpreterInterface
structure is populated with pointers to the callbacks implemented by the user. The expected callback signatures are detailed in Interpreter.h. The callbacks are used as follows:
dwCANInterpreterInterface.addMessage
gets called with a dwCANMessage
to be interpreteddwCANInterpreterInterface.getNumAvailableSignals
and dwCANInterpreterInterface.getSignalInfo
are used to extract signals from CAN messagesdwCANInterpreterInterface.getDataf32
, dwCANInterpreterInterface.getDataf64
and dwCANInterpreterInterface.getDatai32
are used to read the corresponding signal type data from each messageThe following callbacks are required to be implemented:
addMessage
getNumAvailableSignals
getSignalInfo
The following callbacks are optional and have to be implemented only if a signal data type requires them:
getDataf32
getDataf64
getDatai32
An example implementation of those callbacks is provided in CAN Message Interpreter Sample
CAN messages can be provided to the interpreter for parsing as follows:
Then used as follows:
The above snippet iterates over all signals handled by the intepreter, and attempts to read a value for each signal, in the latest consumed dwCANMessage
.
Note that in general the number of signals as returned by dwCANInterpreter_getNumberSignals()
is the number of valid signals found in last consumed CAN message. However this does not have to be true in user-provided callback based interpreters, as it is implementation dependent.
The interpreter can be released as follows:
For more details see CAN Message Interpreter Sample