[fpc-pascal] Ethernet Relays
James Richters
james at productionautomation.net
Sun Sep 6 16:11:23 CEST 2020
I've been using simpleget to control ethernet relays like this:
S:=TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/30000/15');
But if the IP address does not exist on the network I get this error:
An unhandled exception occurred at $0000000100032A4A:
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 <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of James Richters
Sent: Monday, May 25, 2020 8:19 AM
To: 'FPC-Pascal users discussions' <fpc-pascal at lists.freepascal.org>
Subject: Re: [fpc-pascal] Ethernet Relays
Thank you Michael, I would have really overcomplicated that, glad I asked
James
-----Original Message-----
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of Michael Van Canneyt
Sent: Monday, May 25, 2020 6:54 AM
To: james at productionautomation.net; FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
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/30000/01',L);
finally
L.Free;
end;
Michael.
>
> James
>
> -----Original Message-----
> From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf
> Of Michael Van Canneyt
> Sent: Monday, May 25, 2020 4:47 AM
> To: james at productionautomation.net; FPC-Pascal users discussions
> <fpc-pascal at lists.freepascal.org>
> Cc: 'Ched' <charles.edouard.des.vastes.vignes at gmail.com>
> 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/30000/01');
>> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/30000/03');
>> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/30000/05');
>> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/30000/07');
>> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/30000/43');
>> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/30000/09');
>> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/30000/11');
>> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/30000/13');
>> TFPHTTPCLIENT.SIMPLEGET('http://10.10.01.01/30000/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/30000/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 at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal at lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal at lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list