Error in code generation using simulink coder
15 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Aiswarya
on 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).
0 Comments
See Also
Categories
Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!