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

2 ビュー (過去 30 日間)
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.

採用された回答

MathWorks Support Team
MathWorks Support Team 2020 年 3 月 26 日
編集済み: MathWorks Support Team 2020 年 3 月 26 日
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 件のコメント
Stefanie Schwarz
Stefanie Schwarz 2019 年 4 月 2 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVehicle Network Toolbox についてさらに検索

タグ

タグが未入力です。

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by