How can I perform an HTTP POST from a Simulink Model which should also be able to run on a Raspberry Pi?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 9 Jan. 2018
Bearbeitet: MathWorks Support Team
am 1 Jun. 2023
I have developed a Simulink model which should now POST a computed value to a web service over HTTP every once in a while. I could accomplish that inside MATLAB/Simulink by making a call to "websave", as an extrinsic in a MATLAB Function block or through a Level 2 MATLAB S-Function, but in the end I want to deploy my model to run on a Raspberry Pi and those options will not work then (since those are not supported for code generation). How can I perform the POST in such a way that the model can also be deployed to a Raspberry Pi?
Akzeptierte Antwort
MathWorks Support Team
am 1 Jun. 2023
Bearbeitet: MathWorks Support Team
am 1 Jun. 2023
A possible solution here is to develop your own "Device Driver Block" which would allow you to use "webwrite" as long as your model still runs inside MATLAB/Simulink and which calls into native libraries available on the Raspberry Pi when deployed to the Pi. Attached to this article is an example which illustrates this and which can be further customized to suit your exact needs. This example follows the same structure, and it based on the same templates as used in the "Create a Digital Write Block" example from the documentation, see:
Further, it makes use of libcurl for performing the requests. libcurl is not installed on the default MathWorks Raspbian image; to install it, ssh into the Raspberry Pi and use the following command to install the library:
sudo apt-get install libcurl3-dev
The model included with the example illustrates the various ways in which the custom Device Driver Block could be used.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Simulink Support Package for Raspberry Pi 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!