Why are the parameters of the CAN Pack or CAN Unpack block not transmitted correctly when I modify them with set_param?

4 visualizaciones (últimos 30 días)
I have trouble changing the parameter of a CAN Pack or CAN Unpack block with set_param.
My goal is to implement a GUI that interacts with the Simulink model.
When I modify the parameters of the block from MATLAB, then it seems that the parameter are set correctly (just looking at the block).
However, the the CAN message is not recognized by a control unit connected to the CAN bus. I have to open the blocks mask manually and click on OK so that the CAN message can be transmitted correctly.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 26 de Mzo. de 2020
Editada: MathWorks Support Team el 26 de Mzo. de 2020
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”:
  1. Copy "privatecanslsignalvalidation_prog.m" into [matlabroot '\toolbox\shared\can\canmasks\private'
  2. Execute: >> rehash toolbox
  1 comentario
Stefanie Schwarz
Stefanie Schwarz el 2 de Abr. de 2019
Tip: Using the attached small wrapper around configure_CANMsgBlock_CANdb, you can directly re-load a CAN database file into the block. Simply add refreshCANdb(gcb) to the InitFcn callback of the CAN Pack / Unpack blocks. Then, the DBC file will be automatically reloaded at the beginning of the code generation process.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Vehicle Network Toolbox en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by