Is there an easy way to get Embedded Coder to use Simulink signal names in C code?

14 次查看(过去 30 天)
I have a model named "GC" and I want Embedded Coder to use the signal names I defined in Simulink in the generated C code. I set the Code Generation Identifiers for global and local variables, types, field names, etc. to 'GC_$N$M'. Now if I have a Simulink signal named "TestSignal", I'd expect to find it in the code as something like "GC_TestSignal", however everything I can find in my generated code are ouput names of subsystems or stuff like "GC_Multiply4"...
I found a solution here: How can I tell Simulink Embedded Coder to get its variable names from my signal names, not the source block names? - (mathworks.com), but thats a lot of work to do, if you have a finished model with thousands of signals. Long story short: Is there a easier war to tell Embedded Coder to use my signal names or am I missing something here?

回答(1 个)

Kausthub
Kausthub 2023-10-13
Hi Matthias Em,
I understand that you have set the Code Generation Identifiers to “GC_$N$M” and would like to have variables names with format “GC_TestSignal” in the generated C code.
The “$N” in “GC_$N$M” refers to the name of the object (block, signal or signal object, state, parameter or parameter object) being identified and in most cases by default “$N” would be the name of the signal itself. However, if the signal name is not provided, "$N" would be the name of the block.
The reason why the name “GC_Multiply4” is being generated is because the signal name is not provided and “$N” in this case would be the name of the block, which is “Multiply”.
Please note that if you are only changing the names of signals and blocks, the code will not be updated after code generation. This is because no structural, parameter, or code replacement library changes would be detected. To reflect the new names, please delete the previously generated code and try generating the code again.
For more information, you can refer to the following documentation pages:
I hope this explanation helps and resolves your query about using signal names for variables while generating C code using Embedder Coder.

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by