Re: [fpc-pascal] Ethernet Relays
I put my project to control these ethernet relays on Git Hub at https://github.com/Zaaphod/Ethernet-HTTP-Relays/ I thought I would post it here so if someone comes across this while searching for information about them they will find it. This is a library to control Ethernet Relays that use web browser commands similar to: * http://192.168.1.4/3/00 : Relay-01 OFF * http://192.168.1.4/3/01 : Relay-01 ON * http://192.168.1.4/3/02 : Relay-02 OFF * http://192.168.1.4/3/03 : Relay-02 ON * http://192.168.1.4/3/04 : Relay-03 OFF * Http://192.168.1.4/3/05 : Relay-03 ON * ... * http://192.168.1.4/3/30 : Relay-16 OFF * http://192.168.1.4/3/31 : Relay-16 ON * http://192.168.1.4/3/41 : Enter * http://192.168.1.4/3/40 : Exit * http://192.168.1.4/3/42 : Next Page * http://192.168.1.4/3/43 : Next Page These Relays are inexpensive and come either with a relay board or made to attach to common relay boards It was tested with these boards: * 16 Relay: https://www.amazon.com/gp/product/B00NDS9LBK (Controller) With https://www.amazon.com/gp/product/B07Y2X4F77 (Relay Board) * 8 Relay: https://www.amazon.com/gp/product/B076CNJNFH (comes with both the controller and the relay board) It allows you to turn any relay on or off programmatically without using a web browser It also deciphers the pages provided by the board's web server to all you to programmatically get the status of each relay It can control multiple relay boards at the same time, they are referenced by their IP Address James ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
On Tue, 8 Sep 2020, James Richters via fpc-pascal wrote: Yes 10 was too short, I made it larger and larger until it worked. 1000 was the lowest value that worked so I set it to 2000, that's still quite a bit faster than the default. If I make a mistake in the link but the server IP address is correct, I get a valid connection but then it fails and terminates with: An unhandled exception occurred at $000100017675: EHTTPClient: Unexpected response status code: 401 If I use the wrong IP address, but that IP address has a different server running on it, but that page is not available, I get: An unhandled exception occurred at $000100017675: EHTTPClient: Unexpected response status code: 401 Is there a way to obtain these errors as well so it doesn't terminate my program? Yes, catch the EHTTPClient exception just as you catch the ESocketError: try S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server: ',E.Message); On EH : EHTTPClient do begin Writeln('Error getting the document : '+EH.Message); end; end; If you created a TFPHTTPClient instance you can also examine the ResponseStatusCode property, it will contain the server response code. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
Yes 10 was too short, I made it larger and larger until it worked. 1000 was the lowest value that worked so I set it to 2000, that's still quite a bit faster than the default. If I make a mistake in the link but the server IP address is correct, I get a valid connection but then it fails and terminates with: An unhandled exception occurred at $000100017675: EHTTPClient: Unexpected response status code: 401 If I use the wrong IP address, but that IP address has a different server running on it, but that page is not available, I get: An unhandled exception occurred at $000100017675: EHTTPClient: Unexpected response status code: 401 Is there a way to obtain these errors as well so it doesn't terminate my program? James -Original Message- From: fpc-pascal On Behalf Of Michael Van Canneyt via fpc-pascal Sent: Tuesday, September 8, 2020 7:44 AM To: James Richters ; FPC-Pascal users discussions Cc: Michael Van Canneyt Subject: Re: [fpc-pascal] Ethernet Relays On Tue, 8 Sep 2020, James Richters via fpc-pascal wrote: > I added ssockets now I can compile it. > > I have this working with the ssockets unit added: > Try > S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); > except > On E: ESocketError do > Writeln('Could not connect to server'); end; > > But when I try the version with the timeout, I always get the error. > What is the proper way to get the page into a variable with the timeout > method? > I tried S:= C.Get('http://10.10.01.01/3/15'); But I'm not sure > that's the right way to do it, but even without the S:= I always get > the EsocketError What timeout did you use ? 10 ms is probably too short. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
On Tue, 8 Sep 2020, James Richters via fpc-pascal wrote: I added ssockets now I can compile it. I have this working with the ssockets unit added: Try S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; But when I try the version with the timeout, I always get the error. What is the proper way to get the page into a variable with the timeout method? I tried S:= C.Get('http://10.10.01.01/3/15'); But I'm not sure that's the right way to do it, but even without the S:= I always get the EsocketError What timeout did you use ? 10 ms is probably too short. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
I added ssockets now I can compile it. I have this working with the ssockets unit added: Try S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; But when I try the version with the timeout, I always get the error. What is the proper way to get the page into a variable with the timeout method? I tried S:= C.Get('http://10.10.01.01/3/15'); But I'm not sure that's the right way to do it, but even without the S:= I always get the EsocketError uses fphttpclient,ssockets; Var C : TFPHTTPClient; begin C:=TFPHTTPClient.Create(Nil); try try C.ConnectTimeout:=10; // Or whatever you think is good C.Get('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; finally C.Free; end; end; James -Original Message- From: fpc-pascal On Behalf Of Michael Van Canneyt via fpc-pascal Sent: Tuesday, September 8, 2020 2:51 AM To: James Richters ; FPC-Pascal users discussions Cc: Michael Van Canneyt Subject: Re: [fpc-pascal] Ethernet Relays Add the ssockets unit to your uses clause. Michael On Mon, 7 Sep 2020, James Richters via fpc-pascal wrote: > When I try to compile either of the examples below, I get Error: Identifier > not found "ESocketError" > Any ideas? > > James > > > Yes, catch the ESocketError in a try..except: > > Try > S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); > except > On E: ESocketError do > Writeln('Could not connect to server'); end; > >> Is there a way to change the amount of time before the timeout? > > Yes, but then you need to create an instance, i.e. the Simple* commands won't > do that for you: > > Instead, it will look like this: > > uses fphttpclient; > > Var > C : TFPHTTPClient; > > begin > C:=TFPHTTPClient.Create(Nil); > try > try >C.ConnectTimeout:=10; // Or whatever you think is good >C.Get('http://10.10.01.01/3/15'); > except >On E: ESocketError do > Writeln('Could not connect to server'); > end; > finally > C.Free; > end; > end; > > Michael. > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
Add the ssockets unit to your uses clause. Michael On Mon, 7 Sep 2020, James Richters via fpc-pascal wrote: When I try to compile either of the examples below, I get Error: Identifier not found "ESocketError" Any ideas? James Yes, catch the ESocketError in a try..except: Try S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; Is there a way to change the amount of time before the timeout? Yes, but then you need to create an instance, i.e. the Simple* commands won't do that for you: Instead, it will look like this: uses fphttpclient; Var C : TFPHTTPClient; begin C:=TFPHTTPClient.Create(Nil); try try C.ConnectTimeout:=10; // Or whatever you think is good C.Get('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; finally C.Free; end; end; Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
When I try to compile either of the examples below, I get Error: Identifier not found "ESocketError" Any ideas? James Yes, catch the ESocketError in a try..except: Try S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; > Is there a way to change the amount of time before the timeout? Yes, but then you need to create an instance, i.e. the Simple* commands won't do that for you: Instead, it will look like this: uses fphttpclient; Var C : TFPHTTPClient; begin C:=TFPHTTPClient.Create(Nil); try try C.ConnectTimeout:=10; // Or whatever you think is good C.Get('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; finally C.Free; end; end; Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
Thanks Michael, I'll give it a try James -Original Message- From: fpc-pascal On Behalf Of Michael Van Canneyt via fpc-pascal Sent: Sunday, September 6, 2020 11:12 AM To: James Richters ; FPC-Pascal users discussions Cc: Michael Van Canneyt Subject: Re: [fpc-pascal] Ethernet Relays On Sun, 6 Sep 2020, James Richters via fpc-pascal wrote: > I've been using simpleget to control ethernet relays like this: > S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); > > But if the IP address does not exist on the network I get this error: > > An unhandled exception occurred at $000100032A4A: > ESocketError: Connection to 10.10.01.01:80 timed out. > > And my program terminates. Is there some way I can capture this error > with my program so I can just put up a message about the problem and > keep running? Yes, catch the ESocketError in a try..except: Try S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; > Is there a way to change the amount of time before the timeout? Yes, but then you need to create an instance, i.e. the Simple* commands won't do that for you: Instead, it will look like this: uses fphttpclient; Var C : TFPHTTPClient; begin C:=TFPHTTPClient.Create(Nil); try try C.ConnectTimeout:=10; // Or whatever you think is good C.Get('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; finally C.Free; end; end; Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
On Sun, 6 Sep 2020, James Richters via fpc-pascal wrote: I've been using simpleget to control ethernet relays like this: S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); But if the IP address does not exist on the network I get this error: An unhandled exception occurred at $000100032A4A: ESocketError: Connection to 10.10.01.01:80 timed out. And my program terminates. Is there some way I can capture this error with my program so I can just put up a message about the problem and keep running? Yes, catch the ESocketError in a try..except: Try S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; Is there a way to change the amount of time before the timeout? Yes, but then you need to create an instance, i.e. the Simple* commands won't do that for you: Instead, it will look like this: uses fphttpclient; Var C : TFPHTTPClient; begin C:=TFPHTTPClient.Create(Nil); try try C.ConnectTimeout:=10; // Or whatever you think is good C.Get('http://10.10.01.01/3/15'); except On E: ESocketError do Writeln('Could not connect to server'); end; finally C.Free; end; end; Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
I've been using simpleget to control ethernet relays like this: S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); But if the IP address does not exist on the network I get this error: An unhandled exception occurred at $000100032A4A: ESocketError: Connection to 10.10.01.01:80 timed out. And my program terminates. Is there some way I can capture this error with my program so I can just put up a message about the problem and keep running? Is there a way to change the amount of time before the timeout? James -Original Message- From: fpc-pascal On Behalf Of James Richters Sent: Monday, May 25, 2020 8:19 AM To: 'FPC-Pascal users discussions' Subject: Re: [fpc-pascal] Ethernet Relays Thank you Michael, I would have really overcomplicated that, glad I asked James -Original Message- From: fpc-pascal On Behalf Of Michael Van Canneyt Sent: Monday, May 25, 2020 6:54 AM To: ja...@productionautomation.net; FPC-Pascal users discussions Subject: Re: [fpc-pascal] Ethernet Relays On Mon, 25 May 2020, James Richters wrote: > Thanks! > > Is there some convenient way to get the HTML into a Tstringlist? Yes. Simpleget is overloaded to accept a tstrings: L:=TstringList.Create; try TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/01',L); finally L.Free; end; Michael. > > James > > -Original Message- > From: fpc-pascal On Behalf > Of Michael Van Canneyt > Sent: Monday, May 25, 2020 4:47 AM > To: ja...@productionautomation.net; FPC-Pascal users discussions > > Cc: 'Ched' > Subject: Re: [fpc-pascal] Ethernet Relays > > > > On Sun, 24 May 2020, James Richters wrote: > >> I got this working, thanks for the advice Ched, >> >> Here's my test program: >> uses fphttpclient; >> Begin >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/01'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/03'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/05'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/07'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/43'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/09'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/11'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/13'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); >> End. >> >> I have to give it a command to go the next page for some reason or >> relays >> 5-8 won't work... so now I'm wondering if there is a way I can >> retrieve the data that is normally displayed in my browser to I can >> see what page number I'm on, I could also then check the status of >> the relays as well by analyzing what I read. > > Simpleget is a function that returns the page: > > S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); > > S will contain the page of HTML. > > If you need to send a command, you'll probably need to use > SimplePost() > > Michael. > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
Thank you Michael, I would have really overcomplicated that, glad I asked James -Original Message- From: fpc-pascal On Behalf Of Michael Van Canneyt Sent: Monday, May 25, 2020 6:54 AM To: ja...@productionautomation.net; FPC-Pascal users discussions Subject: Re: [fpc-pascal] Ethernet Relays On Mon, 25 May 2020, James Richters wrote: > Thanks! > > Is there some convenient way to get the HTML into a Tstringlist? Yes. Simpleget is overloaded to accept a tstrings: L:=TstringList.Create; try TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/01',L); finally L.Free; end; Michael. > > James > > -Original Message- > From: fpc-pascal On Behalf > Of Michael Van Canneyt > Sent: Monday, May 25, 2020 4:47 AM > To: ja...@productionautomation.net; FPC-Pascal users discussions > > Cc: 'Ched' > Subject: Re: [fpc-pascal] Ethernet Relays > > > > On Sun, 24 May 2020, James Richters wrote: > >> I got this working, thanks for the advice Ched, >> >> Here's my test program: >> uses fphttpclient; >> Begin >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/01'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/03'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/05'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/07'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/43'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/09'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/11'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/13'); >> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); >> End. >> >> I have to give it a command to go the next page for some reason or >> relays >> 5-8 won't work... so now I'm wondering if there is a way I can >> retrieve the data that is normally displayed in my browser to I can >> see what page number I'm on, I could also then check the status of >> the relays as well by analyzing what I read. > > Simpleget is a function that returns the page: > > S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); > > S will contain the page of HTML. > > If you need to send a command, you'll probably need to use > SimplePost() > > Michael. > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
On Mon, 25 May 2020, James Richters wrote: Thanks! Is there some convenient way to get the HTML into a Tstringlist? Yes. Simpleget is overloaded to accept a tstrings: L:=TstringList.Create; try TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/01',L); finally L.Free; end; Michael. James -Original Message- From: fpc-pascal On Behalf Of Michael Van Canneyt Sent: Monday, May 25, 2020 4:47 AM To: ja...@productionautomation.net; FPC-Pascal users discussions Cc: 'Ched' Subject: Re: [fpc-pascal] Ethernet Relays On Sun, 24 May 2020, James Richters wrote: I got this working, thanks for the advice Ched, Here's my test program: uses fphttpclient; Begin TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/01'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/03'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/05'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/07'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/43'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/09'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/11'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/13'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); End. I have to give it a command to go the next page for some reason or relays 5-8 won't work... so now I'm wondering if there is a way I can retrieve the data that is normally displayed in my browser to I can see what page number I'm on, I could also then check the status of the relays as well by analyzing what I read. Simpleget is a function that returns the page: S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); S will contain the page of HTML. If you need to send a command, you'll probably need to use SimplePost() Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
Thanks! Is there some convenient way to get the HTML into a Tstringlist? James -Original Message- From: fpc-pascal On Behalf Of Michael Van Canneyt Sent: Monday, May 25, 2020 4:47 AM To: ja...@productionautomation.net; FPC-Pascal users discussions Cc: 'Ched' Subject: Re: [fpc-pascal] Ethernet Relays On Sun, 24 May 2020, James Richters wrote: > I got this working, thanks for the advice Ched, > > Here's my test program: > uses fphttpclient; > Begin > TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/01'); > TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/03'); > TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/05'); > TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/07'); > TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/43'); > TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/09'); > TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/11'); > TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/13'); > TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); > End. > > I have to give it a command to go the next page for some reason or > relays > 5-8 won't work... so now I'm wondering if there is a way I can > retrieve the data that is normally displayed in my browser to I can > see what page number I'm on, I could also then check the status of > the relays as well by analyzing what I read. Simpleget is a function that returns the page: S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); S will contain the page of HTML. If you need to send a command, you'll probably need to use SimplePost() Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
On Sun, 24 May 2020, James Richters wrote: I got this working, thanks for the advice Ched, Here's my test program: uses fphttpclient; Begin TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/01'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/03'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/05'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/07'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/43'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/09'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/11'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/13'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); End. I have to give it a command to go the next page for some reason or relays 5-8 won't work... so now I'm wondering if there is a way I can retrieve the data that is normally displayed in my browser to I can see what page number I'm on, I could also then check the status of the relays as well by analyzing what I read. Simpleget is a function that returns the page: S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); S will contain the page of HTML. If you need to send a command, you'll probably need to use SimplePost() Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
I got this working, thanks for the advice Ched, Here's my test program: uses fphttpclient; Begin TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/01'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/03'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/05'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/07'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/43'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/09'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/11'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/13'); TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/3/15'); End. I have to give it a command to go the next page for some reason or relays 5-8 won't work... so now I'm wondering if there is a way I can retrieve the data that is normally displayed in my browser to I can see what page number I'm on, I could also then check the status of the relays as well by analyzing what I read. James -Original Message- From: fpc-pascal On Behalf Of James Richters Sent: Sunday, May 24, 2020 3:41 PM To: 'FPC-Pascal users discussions' Cc: 'Ched' Subject: Re: [fpc-pascal] Ethernet Relays Thanks!! I'm happy with http, I should have mentioned I'm on Windows 10, any issues with that unit under windows? James -Original Message- From: fpc-pascal On Behalf Of Ched via fpc-pascal Sent: Sunday, May 24, 2020 3:02 PM To: fpc-pascal@lists.freepascal.org Cc: Ched Subject: Re: [fpc-pascal] Ethernet Relays Hello James, You'll find a source of happiness with unit fphttpclient . Particularily with the simplget function: TFPHTTPCLIENT.SIMPLEGET('http://192.168.1.4/3/00') It is said that it works with https also, but under the Mageia7 distro, you probably encounter problems I haven't yet solved. But for http, that should be right. Cheers, Ched Le 24.05.20 à 18:46, James Richters a écrit : > Does anyone have any advice on how to get started sending commands from FPC > to use these ethernet relays: > > https://www.amazon.com/gp/product/B076CNJNFH > > > Default IP :192.168.1.4 prot:3http://192.168.1.4/3 > > HTTP Comment: > http://192.168.1.4/3/00 : Relay-01 OFF > http://192.168.1.4/3/01 : Relay-01 ON > http://192.168.1.4/3/02 : Relay-02 OFF > http://192.168.1.4/3/03 : Relay-02 ON > http://192.168.1.4/3/04 : Relay-03 OFF > http://192.168.1.4/3/05 : Relay-03 ON ... > http://192.168.1.4/3/14 : Relay-8 OFF > http://192.168.1.4/3/15 : Relay-8 ON > http://192.168.1.4/3/41 : Enter > http://192.168.1.4/3/40 : Exit > http://192.168.1.4/3/42 : Next Page > http://192.168.1.4/3/43 : Next Page > > I don't really know what I even need to do to send commands like that over > the network. Of course I can get it to work just typing the commands from a > browser but that's not what I want, I want my FPC console program to send the > appropriate commands whenever I want one of the relays to come on or go off. > > Any suggestions on how this might be accomplished? > > James > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
Thanks!! I'm happy with http, I should have mentioned I'm on Windows 10, any issues with that unit under windows? James -Original Message- From: fpc-pascal On Behalf Of Ched via fpc-pascal Sent: Sunday, May 24, 2020 3:02 PM To: fpc-pascal@lists.freepascal.org Cc: Ched Subject: Re: [fpc-pascal] Ethernet Relays Hello James, You'll find a source of happiness with unit fphttpclient . Particularily with the simplget function: TFPHTTPCLIENT.SIMPLEGET('http://192.168.1.4/3/00') It is said that it works with https also, but under the Mageia7 distro, you probably encounter problems I haven't yet solved. But for http, that should be right. Cheers, Ched Le 24.05.20 à 18:46, James Richters a écrit : > Does anyone have any advice on how to get started sending commands from FPC > to use these ethernet relays: > > https://www.amazon.com/gp/product/B076CNJNFH > > > Default IP :192.168.1.4 prot:3http://192.168.1.4/3 > > HTTP Comment: > http://192.168.1.4/3/00 : Relay-01 OFF > http://192.168.1.4/3/01 : Relay-01 ON > http://192.168.1.4/3/02 : Relay-02 OFF > http://192.168.1.4/3/03 : Relay-02 ON > http://192.168.1.4/3/04 : Relay-03 OFF > http://192.168.1.4/3/05 : Relay-03 ON ... > http://192.168.1.4/3/14 : Relay-8 OFF > http://192.168.1.4/3/15 : Relay-8 ON > http://192.168.1.4/3/41 : Enter > http://192.168.1.4/3/40 : Exit > http://192.168.1.4/3/42 : Next Page > http://192.168.1.4/3/43 : Next Page > > I don't really know what I even need to do to send commands like that over > the network. Of course I can get it to work just typing the commands from a > browser but that's not what I want, I want my FPC console program to send the > appropriate commands whenever I want one of the relays to come on or go off. > > Any suggestions on how this might be accomplished? > > James > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Ethernet Relays
Hello James, You'll find a source of happiness with unit fphttpclient . Particularily with the simplget function: TFPHTTPCLIENT.SIMPLEGET('http://192.168.1.4/3/00') It is said that it works with https also, but under the Mageia7 distro, you probably encounter problems I haven't yet solved. But for http, that should be right. Cheers, Ched Le 24.05.20 à 18:46, James Richters a écrit : Does anyone have any advice on how to get started sending commands from FPC to use these ethernet relays: https://www.amazon.com/gp/product/B076CNJNFH Default IP :192.168.1.4 prot:3http://192.168.1.4/3 HTTP Comment: http://192.168.1.4/3/00 : Relay-01 OFF http://192.168.1.4/3/01 : Relay-01 ON http://192.168.1.4/3/02 : Relay-02 OFF http://192.168.1.4/3/03 : Relay-02 ON http://192.168.1.4/3/04 : Relay-03 OFF http://192.168.1.4/3/05 : Relay-03 ON ... http://192.168.1.4/3/14 : Relay-8 OFF http://192.168.1.4/3/15 : Relay-8 ON http://192.168.1.4/3/41 : Enter http://192.168.1.4/3/40 : Exit http://192.168.1.4/3/42 : Next Page http://192.168.1.4/3/43 : Next Page I don't really know what I even need to do to send commands like that over the network. Of course I can get it to work just typing the commands from a browser but that's not what I want, I want my FPC console program to send the appropriate commands whenever I want one of the relays to come on or go off. Any suggestions on how this might be accomplished? James ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Ethernet Relays
Does anyone have any advice on how to get started sending commands from FPC to use these ethernet relays: https://www.amazon.com/gp/product/B076CNJNFH Default IP :192.168.1.4 prot:3http://192.168.1.4/3 HTTP Comment: http://192.168.1.4/3/00 : Relay-01 OFF http://192.168.1.4/3/01 : Relay-01 ON http://192.168.1.4/3/02 : Relay-02 OFF http://192.168.1.4/3/03 : Relay-02 ON http://192.168.1.4/3/04 : Relay-03 OFF http://192.168.1.4/3/05 : Relay-03 ON ... http://192.168.1.4/3/14 : Relay-8 OFF http://192.168.1.4/3/15 : Relay-8 ON http://192.168.1.4/3/41 : Enter http://192.168.1.4/3/40 : Exit http://192.168.1.4/3/42 : Next Page http://192.168.1.4/3/43 : Next Page I don't really know what I even need to do to send commands like that over the network. Of course I can get it to work just typing the commands from a browser but that's not what I want, I want my FPC console program to send the appropriate commands whenever I want one of the relays to come on or go off. Any suggestions on how this might be accomplished? James ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal