Check model version consistency between generated code and model

Hello experts,
a Simulink model is equipped with a "Model Version", which is increased every time a change in a model is saved. We can read this from the model via
get_param(model,'ModelVersion')
If we generate code from this model, the *.c and *.h files also include this model version, e.g.
* Code generated for Simulink model 'FeatureName_GENCODE_mdl'.
*
* Model version : 1.44
* Simulink Coder version : 9.8 (R2022b) 13-May-2022
* C/C++ source code generated on : Tue Feb 27 07:46:12 2024
Is there an option, to retrieve the model version from generated code programmatically, to check the consistency of model versions between generated code and model (despite performing SIL/PIL tests)?
To manually parse generated C-Code in MATLAB and search for Model version seems a bit unclean to me. Is there a better option?
Many Thanks and BR!

 採用された回答

Mark McBroom
Mark McBroom 2024 年 3 月 16 日
編集済み: Mark McBroom 2024 年 3 月 16 日

0 投票

I do not think the Model version is available, however, you can use get_param(model,'ModelVersion") from the model, and then compare the checksums for the model and generated code to confirm that the code is from the current version of the model:
To get model checksum:
Simulink.BlockDiagram.getChecksum(model)
To get checksum for generated code:
Navigate into the code generation directory
load codeInfo.mat
codeInfo.Checksum
If the two checksums match, then the generate code is from the current version of the model.

1 件のコメント

flrhlt
flrhlt 2024 年 3 月 18 日
Thank's for this hint! Checksum is much better than version.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink Coder についてさらに検索

質問済み:

2024 年 2 月 27 日

コメント済み:

2024 年 3 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by