How can I perform an HTTP POST from a Simulink Model which should also be able to run on a Raspberry Pi?
2 visualizzazioni (ultimi 30 giorni)
MathWorks Support Team il 9 Gen 2018
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?
MathWorks Support Team il 1 Giu 2023
Modificato: MathWorks Support Team il 1 Giu 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.
Più risposte (0)