How can self-organized Simulink model/block information be written to a file during Simulink code generation?
I maintain some data structures in the callback functions of my customized Simulink blocks and would like to write them to a source file or a formatted configuration file when generating C code. Simulink can load custom TLC (Target Language Compiler) files through a custom System Target File and read model configuration information. TLC can read model configurations or RTW files to obtain model-related information and write the relevant data into C source files or header files. However, TLC doesn’t handle structured data well.
I have tried the following:
1. Writing data to the MATLAB workspace via the model block callback functions and then reading from TLC, but TLC cannot access the MATLAB workspace (e.g., via TLC `eval` function or %matlab or others) when generating code.
2. Writing data to a custom model configuration page (by modifying the System Target File) and then reading configuration items during TLC code generation, but this is not very friendly for complex data structures.
Is there any elegant way to pass complex private data structures into the source code? This is somewhat similar to a serialization requirement, where the callback function m in the model serializes the data, and then in C language, the data is deserialized and parsed.I maintain some data structures in the callback functions of my customized Simulink blocks and would like to write them to a source file or a formatted configuration file when generating C code. Simulink can load custom TLC (Target Language Compiler) files through a custom System Target File and read model configuration information. TLC can read model configurations or RTW files to obtain model-related information and write the relevant data into C source files or header files. However, TLC doesn’t handle structured data well.
I have tried the following:
1. Writing data to the MATLAB workspace via the model block callback functions and then reading from TLC, but TLC cannot access the MATLAB workspace (e.g., via TLC `eval` function or %matlab or others) when generating code.
2. Writing data to a custom model configuration page (by modifying the System Target File) and then reading configuration items during TLC code generation, but this is not very friendly for complex data structures.
Is there any elegant way to pass complex private data structures into the source code? This is somewhat similar to a serialization requirement, where the callback function m in the model serializes the data, and then in C language, the data is deserialized and parsed. I maintain some data structures in the callback functions of my customized Simulink blocks and would like to write them to a source file or a formatted configuration file when generating C code. Simulink can load custom TLC (Target Language Compiler) files through a custom System Target File and read model configuration information. TLC can read model configurations or RTW files to obtain model-related information and write the relevant data into C source files or header files. However, TLC doesn’t handle structured data well.
I have tried the following:
1. Writing data to the MATLAB workspace via the model block callback functions and then reading from TLC, but TLC cannot access the MATLAB workspace (e.g., via TLC `eval` function or %matlab or others) when generating code.
2. Writing data to a custom model configuration page (by modifying the System Target File) and then reading configuration items during TLC code generation, but this is not very friendly for complex data structures.
Is there any elegant way to pass complex private data structures into the source code? This is somewhat similar to a serialization requirement, where the callback function m in the model serializes the data, and then in C language, the data is deserialized and parsed. simulink, code generation, embedded coder, system target file, tlc MATLAB Answers — New Questions