Code Generation for Model Reference containing noninlined S-Function

7 vues (au cours des 30 derniers jours)
Chris Dyer
Chris Dyer le 18 Avr 2017
Commenté : Chris Dyer le 28 Avr 2017
I have a Simulink model that contains a hand written level 2 C S-Function (for which I have an associated mex file).
This model is included as a model reference in a top level model.
I can generate code at the sub model level containing the S-Function.
When I attempt to generate code at the top model level, I receive an error as below where it attempts to load an empty string as a file, but I cannot see where this empty string is coming from or if I can set it somewhere.
Is it possible to generate code at the top level without inlining the s-function?
Note that the simulation executes from the top level correctly, I just cannot build.
Error using loadTMF
File I/O error on file ''
Operation that caused an error: open
The error that occurred was:
Cannot open file. Existence? Permissions? Memory? . . .
Error in rtwprivate (line 16)
[varargout{1:nargout}] = feval(function_name, varargin{1:end});
Error in coder.internal.processSFunctions
Error in coder.internal.processSFunctions
Error in coder.internal.processSFunctions
Error in coder.internal.ModelBuilder/locNewCodePostCodeGen (line 1616)
coder.internal.processSFunctions( h.ModelName, ...
Error in coder.internal.ModelBuilder/buildProcedure (line 694)
[lCodeGenerationId, rpt_generated_flag] = obj.locNewCodePostCodeGen...
Error in coder.internal.ModelBuilder/make_rtw (line 176)
buildResult = buildProcedure(obj, h, modelName, cs, isSimBuild, lReportInfo);
Error in coder.internal.ModelCodegenMgr/make_rtw (line 8)
buildResult = obj.make_rtw(varargin);
Error in make_rtw (line 18)
buildResult = h.make_rtw(varargin{:});
Error in build_target
Error in build_target
Error in build_model_reference_target
Error in update_model_reference_targets
Error in update_model_reference_targets
Error in update_model_reference_targets
Error in update_model_reference_targets
Error in update_model_reference_targets
Error in build_standalone_rtw_target
Error in slbuild_private
Error in slbuild_private
Error in sl (line 15)
[varargout{1:nargout}]=feval(varargin{:});
Error in slbuild (line 61)
sl('slbuild_private', mdl, varargin{:});
Error in build (line 26)
slbuild('Tata_LPO_1512TC', 'StandaloneRTWTarget','ForceTopModelBuild',true);

Réponse acceptée

Prashant Arora
Prashant Arora le 27 Avr 2017
Hi Chris,
The function loadTMF seems to be related to template make file. Which System target file are you using in your top model? Are you using a toolchain approach or template make file approach?
It is possible to generate code from a referenced model containing a C-mex S function. However, there are a few things which Simulink may ask you to do like setting the "Total Number of Instances of Referenced model allow in top model" to be One and enabling "Support non-inlined S-functions".
  1 commentaire
Chris Dyer
Chris Dyer le 28 Avr 2017
Thanks for your response, I was using the makefile approach, which I could not seem to get to work. There was no particular reason for using this method other than it was our legacy configuration which did not get automatically updated to the toolchain approach.
I did manage to get a configuration to compile with the toolchain approach by setting the total number of instances to 1 as you mentioned.
In the end, the way in which we interface to the generated code required non static globals which did not look possible for the way code is generated with this setting.
I have ended up inlining my s functions now.
I am happy to accept the answer as upgrade to the toolchain approach and set number of instances to 1.
It might also be a nice to have some documentation on the affect this setting may have on the code generation, as I found it hard to get a good understanding of what I can expect the output to look like for different settings.
I am not sure what/where "Support non-inlined S-functions" is, It may be a setting for an older version (I should have mentioned I am using 2017a)
Cheers, Chris

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Deployment, Integration, and Supported Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by