integration_with_other_systems
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
integration_with_other_systems [2019/09/03 13:02] – [Example - connecting to a remote module via its web server] emozolyak | integration_with_other_systems [2021/06/29 15:05] – [Implementing other requests like PUT] emozolyak | ||
---|---|---|---|
Line 4: | Line 4: | ||
This function is available since version 2.6.4520. | This function is available since version 2.6.4520. | ||
+ | |||
+ | ===== POST example ===== | ||
An example of a program executing an HTTPS request to send data as a file at URL https:// | An example of a program executing an HTTPS request to send data as a file at URL https:// | ||
Line 32: | Line 34: | ||
Note that for SSL certificates correctly function, you need to have an exact local time. If there is a significant deviation of the local clock, https requests may not work. We recommend using time synchronization via NTP server. | Note that for SSL certificates correctly function, you need to have an exact local time. If there is a significant deviation of the local clock, https requests may not work. We recommend using time synchronization via NTP server. | ||
+ | |||
+ | ===== GET example ===== | ||
Example of requesting a number in the GET request at URL http:// | Example of requesting a number in the GET request at URL http:// | ||
Line 50: | Line 54: | ||
</ | </ | ||
+ | ===== Implementing other requests like PUT ===== | ||
+ | |||
+ | To implement other requests, you can use special field in the cURL for the custom methods. | ||
+ | |||
+ | Here is the example of PUT request to WebHMI itself from its Lua. | ||
+ | |||
+ | <code lua> | ||
+ | |||
+ | function main (userId) | ||
+ | local new_value = "new string" | ||
+ | write_reg_with_API(1, | ||
+ | end | ||
+ | |||
+ | function write_reg_with_API(reg_id, | ||
+ | | ||
+ | c = cURL.easy_init() | ||
+ | | ||
+ | c: | ||
+ | c: | ||
+ | | ||
+ | c: | ||
+ | c: | ||
+ | | ||
+ | c: | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | }) | ||
+ | | ||
+ | c: | ||
+ | c:close() | ||
+ | end | ||
+ | |||
+ | </ | ||
===== Example - connecting to a remote module via its web server ===== | ===== Example - connecting to a remote module via its web server ===== | ||
Most currently produced remote i/o modules have configuration and status web-page for diagnostic and setup. | Most currently produced remote i/o modules have configuration and status web-page for diagnostic and setup. | ||
- | When you have a module which is not supported | + | When you have a module which is not supported |
- | For a example we have the UC20-FBC-xxx (any bus Modubs, | + | For a example we have the UC20-FBC-xxx (any bus Modubs, |
{{ :: | {{ :: | ||
Line 66: | Line 104: | ||
{{ :: | {{ :: | ||
+ | |||
+ | The function returns json object which you can then analize and check necessary fileds to read: | ||
+ | |||
+ | {{ :: | ||
+ | |||
+ | ===== Notes on cURL usage ===== | ||
+ | |||
+ | <WRAP center round important 80%> | ||
+ | In the fw of 4.0 version, the following issue was reported: | ||
+ | When there are multiple cURL requests from the WebHMI to the unavailable resource, a system crash may happen. The timeout settings won't affect the sysem behaviour. Use this feature with care when you need cyclical calls of multiple cURLs in your scripts: | ||
+ | * use one script which detect availablity of the resource and locks following execution for a while | ||
+ | * use external watchdog circuit to reset WebHMI if you use it to control mission - critical system. | ||
+ | |||
+ | </ | ||
integration_with_other_systems.txt · Last modified: 2024/04/04 10:18 by emozolyak