Azzera filtri
Azzera filtri

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

3 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 1 Apr 2024
Modificato: MathWorks Support Team il 1 Apr 2024
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.

Più risposte (0)

Categorie

Scopri di più su Raspberry Pi Hardware in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Prodotti


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by