Check model version consistency between generated code and model

조회 수: 7 (최근 30일)
flrhlt
flrhlt 2024년 2월 27일
댓글: flrhlt 2024년 3월 18일
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일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by