In an S-Function Block, how do I call functions that are available on my target device but not on my host computer?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 9 Mar 2020
Risposto: MathWorks Support Team
il 6 Apr 2020
In an S-Function Block, how do I call functions that are available on my target device but not on my host computer?
Risposta accettata
MathWorks Support Team
il 9 Mar 2020
In order to get this to work with "coder.ceval()", you have to use "coder.target()" to specify that the functionality that you are leveraging is from the target device. This will cause the specific code to only run on the target device (when deployed) and not when run on the host device (simulated, etc.). Please see the following example:
x = 0;
if coder.target('Rtw')
% generating code for Arduino
coder.cinclude('Arduino.h')
x = coder.ceval('my_arduino_fcn', args...);
else
% simulating in Simulnk
% if there is a way to replicate this behavior in MATLAB, put it here
end
Here, "coder.target('Rtw')" will prevent the next few lines from being executed when running on your host computer, where "Arduino.h" is not defined. For more information on "coder.target()", please refer to the following documentation page:
In this case, you will only want to generate code and not build and run the resulting executable. If you try to run the executable on your host computer, it will fail, since "Arduino.h" and its dependencies are not on the path on your host machine.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Arduino Hardware 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!