Home > Forum > IEC 61131 Programming (LogicLab) > FB HTTPGetPage and the REST service
- This topic has 9 replies, 3 participants and was last updated 5 years, 11 months ago da Sergio Bertana.
-
AuthorPost
-
November 24, 2015 at 9: 43 am #35883AndreaParticipant
I downloaded and installed the new firmware SFW184B000 with the new HTTP management function, I wanted to ask if it was possible to have examples of using the FB HTTPGetPage in ST and in FBD.
November 24, 2015 at 9: 45 am #39208Sergio BertanaAdministrator ForumIn the new firmware the networking management has been completely redesigned with the addition of FBs to manage both client and server connections in UDP and TCP. DNS support for URL resolution has also been introduced. This has made it possible to create a whole series of new FBs dedicated to networking, I suggest you consult the new version of the manual.
The FB HTTPGetPage allows you to act as a common browser by acquiring web pages from HTTP servers, in the manual there is already an example in ladder language that connects to a PHP script posted on a public server. In the example, by activating a digital input, a page request is made on the Altervista website, the Dividend and Divisor parameters are passed in GET 2.
The requested page is a PHP script that performs the division between the passed values. It is possible to test the functioning of the script directly from here http://www.slimline.altervista.org/Mdp095a000/Ptp119b000/Division.php?Dividend=500&Divisor=10.
If the script is active, a page is returned with: The result is: 50. It is obvious that you can test the script by changing the values in the browser address and obtaining different results. The purpose of the FB is precisely this to rely on the program SlimLine on a web service in the cloud to perform operations.
November 24, 2015 at 10: 30 am #39209Sergio BertanaAdministrator ForumI take advantage of the topic to add that the HTTPGetPage FB is the engine of a new library that we have developed for some customers to manage the Internet Of Things using the REST service. We are currently working on this library that we hope to be able to offer as soon as possible, while it is being released in beta mode to customers who request it.
Here is one screenshot of the historical page of the REST site created for a customer who manages industrial refrigerators, where you can see a report with the display of the cold room temperature related to that of the evaporator.
November 24, 2015 at 12: 32 pm #39213AndreaParticipantThe example program proposed in Ptp119b000 and in LD language which is a bit difficult for me, if reproduced in ST and FBD I would understand better how to integrate it into my system, thank you very much.
November 24, 2015 at 2: 57 pm #39214Sergio BertanaAdministrator ForumIn FBD language it is practically the same as LD language, so I preferred to create an example in ST language where I also set up the possibility of passing in GET to the request for variable values and of acquiring the value of the result from the returned string and placing it on a REAL variable (Here she is program printing).
I attach for download the current version of the example program Ptp119b100 with the new program (Download program).
February 24, 2017 at 8: 23 am #39852SergioParticipantHello, I think I have found a bug in the HTTPGetPage FB of eLLabNetworkLib_A200.plclib. If the Request string is empty, an incorrect HTTP request is made, exactly the first line (eg HTTP / path / a / b / c HTTP / 1.1) is repeated as it is also on the second line.
Putting even a single character (HTTPClient.Request: = ADR ('x');) does not cause the problem.
February 25, 2017 at 7: 56 am #39853Sergio BertanaAdministrator ForumThe library is evolving (We are working on eLLabNetworkLib_A400) with improvements and bug solutions, in this version in the FB HTTPGetPage the value of the Request pointer is checked and if it is NULL the correct request is made.
Since the library is not yet officially released, I am attaching the program for download HTTPGetPage which connects to the server on Altervista where a php program performs a division. In the program there is the new version of the HTTPGetPage FB, you can export it and use it in your project (Download program).
February 27, 2017 at 7: 24 pm #39860SergioParticipantThanks for your help, I confirm that the new version does not have the bug reported.
To use it reliably (with a test program that constantly requires new operations via http), however, I had to try to find the right sequence and conditions on Enable and Done, because otherwise after a few requests the FB would jam.
March 2, 2017 at 4: 08 pm #39861Sergio BertanaAdministrator Forumactivating Enable part of the page request at the end is activated Done. On activation of Done, Enable can be reset. If you want to make continuous requests after a program loop you can re-enable Enable. Here is how to execute consecutive requests. Note the sequentiality of the program must be maintained as shown.
HTTPPr(); (* FB execution *)
IF NOT(HTTPPr.Done) AND (HTTPPr.Enable) THEN
i:=SysVarsnprintf(ADR(Request), SIZEOF(Request), ‘Dividend=%.3f’, REAL_TYPE, ADR(Dividend));
i:=SysLWVarsnprintf(ADR(Request), SIZEOF(Request), ‘$26Divisor=%.3f’, REAL_TYPE, ADR(Divisor));
END_IF;HTTPPr.Enable:=NOT(HTTPPr.Done); (* HTTP get page enable *)
May 10, 2018 at 4: 12 pm #44046Sergio BertanaAdministrator ForumThe HTTPGetPage FB has been replaced by the new HTTPClient FB (Topic).
-
AuthorPost
- You must be logged in to reply to this topic.