How can I perform an HTTP POST from a Simulink Model which should also be able to run on a Raspberry Pi?

4 Ansichten (letzte 30 Tage)
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
MathWorks Support Team am 1 Apr. 2024 um 0:00
Bearbeitet: MathWorks Support Team am 1 Apr. 2024 um 23:51
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.

Weitere Antworten (0)

Kategorien

Mehr zu Raspberry Pi Hardware finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by