Check model version consistency between generated code and model

3 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Mark McBroom
Mark McBroom il 16 Mar 2024
Modificato: Mark McBroom il 16 Mar 2024
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.

Più risposte (0)

Categorie

Scopri di più su Simulink Coder in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by