Filter löschen
Filter löschen

CodeGen Error using Grouped custom storage classes (struct / bitfield) with referenced model

21 Ansichten (letzte 30 Tage)
I recieve the following error when trying to codegen with embedded coder:
Error: Simulink Coder Error: Invalid DataScope 'Exported' for custom storage class: Struct
Grouped custom storage classes must be Imported when used with referenced models.
Is there a way to codegen a model that contains a referenced model using custom storage classes (bitfield / struct)?

Akzeptierte Antwort

Harimurali
Harimurali am 29 Feb. 2024
Hi Jake,
The error happens when some of the signals in the referenced model have the built-in "Struct" storage classes. Embedded coder does not support struct storage class with "Exported" data scope in the referenced models. This a documented limitation:
The limitation mentioned is:
If you apply a grouped storage class, such as "Struct" or "Bitfield", to multiple data items, you must set the storage class Data scope property to "Imported" and you must provide the data declaration in an external header file. Grouped storage classes use a single variable in the generated code to represent multiple data objects.
As the scope of the built-in struct storage class is "Exported", the limitation is violated, and the error is shown.
A potential workaround is to use the "Custom Storage Class Designer" to define a struct storage class with imported scope and then import the struct definition using a custom header file. Here is an example where I have defined a new storage class with imported scope and provided the name of a custom header file that includes the definition of the struct:
Please refer the following documentation on information about "Custom Storage Class Designer" :

Weitere Antworten (1)

Mark McBroom
Mark McBroom am 28 Feb. 2024
As the error message indicates, you must write the header file by hand that defines the C structure, and then set the struct storage class to be imported and provide the name of the hand-written header file.
A more mainstream solution is to define a Simulink.Bus rather than a struct storage class. Simulink Buses are fully supported by referenced models.
  1 Kommentar
Jake Gareau
Jake Gareau am 7 Mär. 2024
Bearbeitet: Jake Gareau am 7 Mär. 2024
That is true, however I find I am unable to use a Simulink bus as the control variable for a variant subsystem. I didnt mention this in the original post but I am using bit field in order to group Variant control variables into a structure

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Deployment, Integration, and Supported Hardware finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by