You can create custom Receive and Transmit blocks to use with hardware currently not supported by the Vehicle Network Toolbox™.
Vehicle Network Toolbox blocks use a custom CAN data type. To use the blocks you create with other Vehicle Network Toolbox blocks, register this custom CAN data type.
To use the custom data type defined in the Vehicle Network Toolbox, write a C++ S-function.
To register and use the custom CAN data type, in your S-function:
Define the IMPORT_SCANUTIL identifier that imports the required symbols when you compile the S-function:
Include the can_datatype.h header located in[MATLABROOT]\toolbox\vnt\vntblks\include\candatatype at the top of the S-function:
Link your S-function during build to the scanutil.lib located in the [MATLABROOT]\toolbox\vnt\vntblks\lib\<ARCH> directory. The shared library scanutil.dll, is located in the [MATLABROOT]\bin\<ARCH>
Call this function in mdlInitializeSizes to initialize the custom CAN data type:
Get custom data type ID using ssGetDataTypeId:
dataTypeID = ssGetDataTypeId(S,SL_CAN_MESSAGE_DTYPE_NAME);
Do one of the following:
To create a receive block, set output port data type to CAN_MESSAGE:
ssSetOutputPortDataType(S, portID, dataTypeID );
To create a transmit block, set the input port to CAN_MESSAGE:
ssSetInputPortDataType(S, portID, dataTypeID );
For more information on S-functions, see S-Function Basics.