Check model version consistency between generated code and model

7 次查看(过去 30 天)
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