Using just the Get of a GetSet signal (or at least supressing the Set initialization)
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have some code which worked in MatLab 2008b, defining mpt.Signal objects for my Simulink model's inputs and then auto-coding my model. These inputs come from other modules in my larger codeset, so it is necessary for me to "Get" these values, but to never write to them. While the GetSet custom storage class required me to specify both a "Get" and a "Set" interface, the model never wrote to these inputs so the "Set" interfaces never appeared in the generated code. This is necessary both because these variables belong to other modules and I am not to write to them, and also because the "Set" interfaces are not even defined in the external code.
The problem came when these scripts were used in MatLab 2011a. Now the E-Coder finds it necessary to initalize my GetSet signals, using their "Set" commands. This causes my overall codeset compile to crash, since these "Set" interfaces are never defined. I looked into using other signal types like ImportedExtern and ImportFromfile, but for arrays (which many of these are) they use square-brackets around the index, not parantheses as needed. I also noticed that MatLab 2011a does not initalize all of my inputs through "Set" commands, just some of them, though I cannot figure out the pattern of which ones get initialized and which ones don't.
What I need, simply, is for all of them to not be initialized.
0 comentarios
Respuestas (1)
Gordon Lai
el 18 de Nov. de 2024 a las 17:38
I came across the same in R2020b and found the reason; for what it's worth, and in case it helps someone else, below are my notes:
Regarding the odd initialisation with a call to a set function - that is not even defined in the custom code header files - I found it to be through this initialisation value (in my case in the DataStoreMemory block, but perhaps somewhere similar if implementing differently);
Other data stores use a nominal integer (of 0) with a datatype convert out of the “read” block, and the Simulink.signal link has a uint8 base datatype (before the convert to enum) - corrected and codegen’d successfully.
This has removed it from the init function and into the top of the Rx function, where the get_ActSystype() is called in cgASW_204_Lecu.c line 2179.
Not sure this is the best example implementation of GetSet, but it does at least work.
0 comentarios
Ver también
Categorías
Más información sobre Deployment, Integration, and Supported Hardware 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!