Getting 'empty' Compiled Port Data Types
22 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm trying to write a script to get datatypes of an inport and a outport of a subsytem/block. When I run following command:
get_param(port_handle,'CompiledPortDataType')
an empty array/structure is returned. Model is compiled before running this command. 'CompiledPortDataDimensions' also returns an empty results.
1 Commento
Paul
il 4 Lug 2023
If you do get this sorted out, please post the solution either here and/or in the linked question.
Risposta accettata
Andy Bartlett
il 7 Lug 2023
Modificato: Andy Bartlett
il 7 Lug 2023
Set model in compile mode to access data types
This may be changing, but historically at least, compiled port data types are available only when the model is actively in compiled mode.
mdl = 'fxpdemo_feedback';
open_system(mdl)
% "Lock" model in compiled mode
%
% NOTE: you will not be able to edit or even close model
% until compiled mode is terminated !!!
%
% TIP: Use try catch to avoid being unwittingly stuck in compile mode
%
try
eval([mdl,'([],[],[],''compile'')']);
blk1 = 'fxpdemo_feedback/A2D';
pdt1 = get_param(blk1,'CompiledPortDataTypes');
blk2 = 'fxpdemo_feedback/Controller/Combine Terms';
pdt2 = get_param(blk2,'CompiledPortDataTypes');
catch
end
eval([mdl,'([],[],[],''term'')']);
pdt1, pdt2
3 Commenti
Andy Bartlett
il 7 Lug 2023
1) Yes, there is definitely a more modern syntax to get into compiled mode that what I should. The command you gave looks correct (but I didn't test it).
2) Yes, "must be in compiled mode" is more correct / clearer IMHO.
3) Yes, when stopped in the Simulink debugger, the model should still be "in compiled mode."
Paul
il 8 Lug 2023
Hi Andy,
Thanks for the response. It turns out that this command
set_param(gcs,'SimulationCommand','compile');
results in an error.
Do you know if there is a doc page that discusses all of the valid setting for SimulationCommand? I can only find example uses, but not a complete list.
Più risposte (1)
VBBV
il 3 Lug 2023
Modificato: VBBV
il 3 Lug 2023
Run the model once (insted of just compiling) and check if model generates any data from ports and call or run the command
get_param(port_handle,'CompiledPortDataType')
Possibly no data might have been generated by model
4 Commenti
VBBV
il 4 Lug 2023
Modificato: VBBV
il 4 Lug 2023
Ok. Test your model with valid inputs or input range. Before running your model, check simulation settings also e.g. time scale for simulation etc. A reasonable time duration. If the same problem exists then verify for any model inconsistencies.
BTW , how is the data being read from I/O ports ? Do you use read or some other functions to read data from ports ?
Vedere anche
Categorie
Scopri di più su Programmatic Model Editing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!