In an S-Function Block, how do I call functions that are available on my target device but not on my host computer?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 9 Mär. 2020
Beantwortet: MathWorks Support Team
am 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?
Akzeptierte Antwort
MathWorks Support Team
am 9 Mär. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Arduino Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!