Using MATLAB R2019a or earlier, it is not possible to use 'set_param' to programmatically control certain CAN Pack/Unpack block functionalities (such as CAN database file, or manually configured CAN message/signals). This ability has been added in R2019b.
The following workaround has been tested in MATLAB R2015b:
Find attached "configure_CANMsgBlock_manual.m" (and required privatecanslsignalvalidation_prog.m") and "configure_CANMsgBlock_CANdb.m" as examples of programmatic configuration of a CAN Unpack or CAN Pack block in "manually specified signals" or "CANdb specified signals". Usage example code is also attached.
These functions can be used with the following 4 block configurations:
- CAN Pack with "CANdb specified signals" mode
- CAN Pack with "manually specified signals" mode
- CAN Unpack with "CANdb specified signals" mode
- CAN Unpack with "manually specified signals" mode
Please refer to 'help' for these workaround example functions, as they have usage examples, additional notes, and disclaimers.
This workaround can be used as an alternative to using the set_param directly. For example: * with a "manually specified signals" mode create the msgInfo and signalsInfo structures from scratch (as in "example_usage_manual.m") and use "configure_CANMsgBlock_manual.m" instead of set_param * with "CANdb specified signals" mode use "configure_CANMsgBlock_CANdb.m" instead of set_param (as in "example_usage_CANdb.m").
Installation instructions for “privatecanslsignalvalidation_prog.m”:
- Copy "privatecanslsignalvalidation_prog.m" into [matlabroot '\toolbox\shared\can\canmasks\private'
- Execute: >> rehash toolbox