Azzera filtri
Azzera filtri

Error in code generation using simulink coder

32 visualizzazioni (ultimi 30 giorni)
Luca Bistolfi
Luca Bistolfi il 22 Nov 2023
Risposto: Aiswarya il 28 Nov 2023
Hello, I have this software I am working with for a while and I could compile the code without any issues. From today, even the backup version I kept 'safe' for this kind of issues cannot compile anymore.
The error is:
''For model 'XXX, code mapping of 'Storage Class' to Inport 'ABC' refers to a definition in model code dictionary that does not exist. In Code Mapping Editor, select a valid 'Storage Class' for Inport 'ABC'.''
I never set anything like that and now I have 128 errors like this. How can I solve?

Risposte (1)

Aiswarya
Aiswarya il 28 Nov 2023
Hi,
I understand that you are getting an error related to the Storage class in the code mappings. This may be due to migration of Model Data Configurations to Code Mappings, which can happen if model is created in an older version. You can check your Inport storage class by using the following code:
>> myCodeMappingObj = coder.mapping.api.get("XXX");
>> myInputStorageClass = getInport(myCodeMappingObj,"ABC","StorageClass")
'getInport' is a function you may use to get the code mapping of a particular Inport block. You can also set the desired Storage Class for your specific Inport ("ABC") by using 'setInport' function. You may refer to the following link to know more about the functions provided by the coder mapping API: https://www.mathworks.com/help/rtw/ref/coder.mapping.api.codemapping.html
Since you are getting other errors related to code mappings as well, you can use the below command to set the storage class of all the model parameters to 'Default':
>> setDataDefault(myCodeMappingObj,'ModelParameters','StorageClass','Default')
Then you can loop through the different model elements and assign a different Storage class if necessary. Refer to the following link to know more about the different storage classes available :https://www.mathworks.com/help/rtw/ug/choose-a-built-in-storage-class-for-controlling-data-representation-in-the-generated-code.html
You can edit these settings in the Code Mappings Editor UI as well (https://www.mathworks.com/help/rtw/ref/codemappingseditorc.html).

Categorie

Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by