Open tjacobs2019 opened 5 years ago
@tjacobs2019 I believe this code is SIL-generated, so I'm going to transfer the issue over to that repo.
The answer to your question is no... the code should be valid as-generated. Need a bit to look into this and will get back to you.
Because I don't have your code/model, I'm looking at the ParmTblWValidation.slx
unit test model. In that model, looking at the generated parmTbl.c
, if I trace through all the includes, model.h is never included.
Your errors indicate that a definition of cntl_srm_gains_Tbl
within Controller.h is conflicting with the definition of cntl_srm_gains_Tbl
in cntl_srm_gains.c. Can you help me understand how Controller.h got included in that table definition file?
I had to include the include the 'Controller.h' header file in the table source file, because if I didn't I was getting unknown type name error for 'cntl_srm_gains_Tbl_b' table definition. The 'Controller.h' file contains all of the table definitions.
I wouldn't recommend hand-editing the code.... the idea is that the SIL should generate valid code and the cases where it doesn't are usually an indication of a misconfiguration. It also makes it very hard to help you figure out what's going on because I have no way of know what hand edits you may have made and how those might change the structure of the code.
Assuming we're dealing with unmodified code... the location of the table's type definition depends on the storage class selected for the parameter object. If you're using the utility createCfsTbl()
(which is included with the SIL) to setup that parameter table, the bus will be scoped as Exported
, which should result in the generation of a dedicated header file to define the structure type. That header file will be included by model_types.h
which is included by the table source file, which should resolve all type definitions.
You can see what this looks like by examining the code provided in SIL\tests\eci_compatibility\model
. If you run the following from within that folder (assuming you've added SIL\src
to your matlab path first), you can see the scope assigned to the bus definition is Exported
.
>> init
>> Tbl_b
Tbl_b =
Bus with properties:
Description: ''
DataScope: 'Exported'
HeaderFile: ''
Alignment: -1
Elements: [3×1 Simulink.BusElement]
Generating code, you'll see that Tbl_b.h
is generated containing the definition of the structure type, SILTest_types.h
includes Tbl_b.h
and is included by Tbl.c
which contains the definition of the table, which should be compilable by the elf tool.
You can read more about the valid values of scope and their impact on the generated code in the Simulink help docs.
If you're a configuration which differs from what I've described, could you describe how you're setting up these tables?
Do I have to do any type of table conversion before I build the tables, because none of my tables are being built.
All of my tables are getting the same error that is listed below for that specific table.