When does Simulink.Bus generate header files?

14 visualizaciones (últimos 30 días)
Timo
Timo el 24 de Jun. de 2012
Editada: Friedrich Welck el 27 de Sept. de 2019
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 comentario
Friedrich Welck
Friedrich Welck el 27 de Sept. de 2019
Editada: Friedrich Welck el 27 de Sept. de 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

Iniciar sesión para comentar.

Respuestas (1)

Kaustubha Govind
Kaustubha Govind el 25 de Jun. de 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.
  1 comentario
Timo
Timo el 25 de Jun. de 2012
Thanks for your reply.
What I'd like to do is create and manipulate data structures in MATLAB and then create Simulink.Bus objects using a "struct2bus" function from then. Afterwards, I'd like to use the created header files in my program. Thus, if data types or matrix dimensions change, the header files change with them and I don't need to change anything in my code.
Right now, code generation works. It creates a <modelname>_bus.h containing the struct typedefs. But since the usage of the code within Simulink tends to be a by-product of the actual application of my code, I don't like to include the header files named <modelname>_bus.h in my main project.
As far as I understood, setting the data scope to "exported" creates a header file while setting it to "imported" reads them from the file system. As already mentioned, I'd like to create header files from the MATLAB structs so I don't need to change code in case my data changes (e.g. changing a data maps resolution). But then I could as well just write my own script that generates header files from arbitrary structs. I just thought since this feature is already implemented in Simulink, there's no need to do that myself.

Iniciar sesión para comentar.

Categorías

Más información sobre Composite Interfaces en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by