When does Simulink.Bus generate header files?
18 views (last 30 days)
Show older comments
Hi there,
I have a problem with the code generation in a S-Function Builder block: A part of my model is C-Code that is listet as a library in the library tab of the S-Function Builder block. My Model also uses Buses and the C-Code uses these Buses as structs. The static input data for the model lives in the workspace and are MATLAB-structs that are converted to Simulink.Bus objects. When I set the Bus objects data scope property to 'Auto' and do not provide a Header file name, the builder block generates a sfunname_bus.h header file that works like a charm if I include it in the library C file.
If I do provide a header file name for the bus and set the data scope to 'Exported', the builder block fails to compile the code, complaining that the header files are missing, which makes sense because no header files are generated.
How can I force header file generation of the Simulink.Bus object before the builder block starts the compilation process?
1 Comment
Friedrich Welck
on 27 Sep 2019
Edited: Friedrich Welck
on 27 Sep 2019
Seven years later I'm having the exact same problem.
There is no solution given here. Is there a solution now?
For reference:
I want to generate C-code and I want the bus-definitions to end up in a header file named 'shared_types.h'.
If I set the DataScope of my bus to 'Auto' and set HeaderFile to '' the definition ends up in <model_name>_types.h
If I set the DataScope of my bus to 'Exported' and set HeaderFile to '' nothing happens. No bus definition is created.
If I set the DataScope of my bus to 'Exported' and set HeaderFile to 'shared_types.h' nothing happens. No bus definition is created.
I am using Matlab 2017b
Answers (1)
Kaustubha Govind
on 25 Jun 2012
Not sure if I've understood your question correctly, but shouldn't the solution be to set the data scope to "Auto" as you've already discovered? Setting it to "exported" is incorrect unless you have existing header files that define the structure of the Bus object.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!