MATLAB: Is it possible to suppress the header file generation by the S-Function builder with Simulink 7.3 (R2009a)

builderbuscoderdllembeddedgenerationheaderinterfaceobjectss-functionsimulink

I am generating ERT Code with the Real-Time Workshop Embedded Coder 5.3 (R2009a). As Interface with my custom Code, I am using Bus Objects with about 100 Inputs and 50 Outputs.
After Code generation I want to test the DLL in my Simulink environment. Therefore I am using the S-Function Builder.
Unfortunately the S-Function Builder does not generate the same *_types.h file as the Embedded Coder does. Please see the following example:
A Bus Object "DLL_Output" in the MATLAB workspace is defined with the following fields in the following order:
DLL_Output
+-- Time
+-- Terminal_Condition
+-- PositionX
+-- PositionY
+-- PositionZ
Then the Embedded Coder is generating the correct Header file with a struct in correct order:
typedef struct {
real_T Time
real_T Terminal_Condition
real_T PositionX
real_T PositionY
real_T PositionZ
} DLL_Output;
But the S-Function builder is generating an incorrect header with a struct in some other order:
typedef struct {
real_T Terminal_Condition
real_T PositionX
real_T Time
real_T PositionY
real_T PositionZ
} DLL_Output;
The issue is that this type definition generated by the S-Function builder cannot be used calling the interface of the DLL which was generated with the Embedded Coder.
Is there a workaround for this issue?

Best Answer

  • There are different possibilities to include your generated code into the Simulink Test Environment:
    1) Writing a S-Function by hand
    --> This is not really feasible if you have a huge amount of interface data.
    2) Referencing the (correct) header file generated by Embedded Coder in the top level bus object.
    DLL_Input.Header = 'Model_types.h'
    DLL_Output.Header = 'Model_types.h'
    With this the S-Function Builder
    • will not generate its own header file.
    • manages the memory mapping and allocation in the correct order based on the definition of the bus object.
    With this possibility the DLL interface between the S-Function and the DLL generated with Real-Time Workshop Embedded Coder fits.