Re: [fpc-pascal] How to build for arm6 in RaspberryPi on arm7?

2020-09-08 Thread Bo Berglund via fpc-pascal
On Tue, 8 Sep 2020 20:09:53 +0200, Jonas Maebe via fpc-pascal
 wrote:

>On 08/09/2020 16:13, Bo Berglund via fpc-pascal wrote:
>> This happened also after I ran a Run/CleanUpAndBuild operation, so
>> clearly there is something I am missing here.
>
>Is your FPC installation itself also built for ARMv6? (rtl and packages)
>

No, it is on an RPi4 so it is ArmV7.

I hoped the compiler could be set to use one instruction set or the
other depending on this project setting.

I could presumably build another FPC 3.0.4 using the ArmV6 setting
even though I am on an Armv7 system, right?
But the result has to go somewhere else. Or replace the previous one.

When doing a make install where would 3.0.4V6 go then?
And what about the ~/.fpc,cfg where all of the settings for fpc are
stored, can it be the same for both v6 and v7 compilers?

And finally, how to set Lazarus to use the v6 compiler rather than the
v7?

Or maybe I have to compile fpc for V6 even though I am on V7 and
thereafter only build ArmV6 compatible applications?

Probably also Lazarus itself needs to be recompiled to V6 because
unless that is done there will be problems when it recompiles itself
after package installations...
Especially if FPC has been replaced by a V6 version.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] String literals and code page of .pas source file

2020-09-08 Thread Sven Barth via fpc-pascal
Mattias Gaertner via fpc-pascal  schrieb
am Di., 8. Sep. 2020, 22:32:

> On Tue, 8 Sep 2020 20:27:20 +0200
> Jonas Maebe via fpc-pascal  wrote:
>
> > On 07/09/2020 08:51, LacaK via fpc-pascal wrote:
> >
> > > attached simple Lazarus compilable project (one Form).
> > >
> > > ...
> > > type
> > >   String1250 = type AnsiString(1250);
> > >
> > > const
> > >   c2: AnsiString = 'áéíóčž';
> > >   c3: WideString = 'áéíóčž';
> > >   c4: String1250 = 'áéíóčž';
> > >
> > > { TForm1 }
> > >
> > > procedure TForm1.FormShow(Sender: TObject);
> > > begin
> > >   label1.Caption:='áéíóčž'; // FAIL
> > >   label2.Caption:=c2;   // FAIL
>
> label2.Caption:='a'+c2; // OK
>
> > >   label3.Caption:=c3;   // OK
> > >   label4.Caption:=c4;   // FAIL
> > > end;
>
> Reason is that LCL TLabel.Caption expects UTF-8.
> You can use
>
> label2.Caption:=WinCPToUTF8(c2); // from unit LazUTF8
>
> Maybe SetCaption could check if passed string is not CP_ACP and do a
> conversion.
>

Why does c4 fail however? Shouldn't the compiler insert a type conversion
from codepage 1250 to CP_ACP which is UTF-8 in Lazarus?

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFPObjectlist example

2020-09-08 Thread Sven Barth via fpc-pascal
James Richters via fpc-pascal  schrieb am
Di., 8. Sep. 2020, 20:07:

> What’s the difference between TList and TFPGList?  Which one is better
> for this example?
>
The main difference is that TFPGList ist a generic, thus when you
specialize it with your record you'll have a typesafe object where you
don't need to manually work with pointers while for TList you either need
to work with pointers or declare a descendant with typesafe setters/getters
like you had done in the other mail.
You could also take a look at the generic TList in Generics.Collections
which does not require an = operator like TFPGList does.

Please note that if you work with TFPGList or the Generics.Collection.TList
then you need to modify an entry using a local variable if your entries are
records:

entry := mylist[i];
entry.field := entry.field * 2;
mylist[i] := entry;

This is because the getter for the Items property will provide a /copy/ of
the entry.

With Classes.TList you'd use a pointer however and thus you can modify it
in place.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] String literals and code page of .pas source file

2020-09-08 Thread Mattias Gaertner via fpc-pascal
On Tue, 8 Sep 2020 20:27:20 +0200
Jonas Maebe via fpc-pascal  wrote:

> On 07/09/2020 08:51, LacaK via fpc-pascal wrote:
> 
> > attached simple Lazarus compilable project (one Form).
> > 
> > ...
> > type
> >   String1250 = type AnsiString(1250);
> > 
> > const
> >   c2: AnsiString = 'áéíóčž';
> >   c3: WideString = 'áéíóčž';
> >   c4: String1250 = 'áéíóčž';
> > 
> > { TForm1 }
> > 
> > procedure TForm1.FormShow(Sender: TObject);
> > begin
> >   label1.Caption:='áéíóčž'; // FAIL
> >   label2.Caption:=c2;   // FAIL

label2.Caption:='a'+c2; // OK

> >   label3.Caption:=c3;   // OK
> >   label4.Caption:=c4;   // FAIL
> > end;  

Reason is that LCL TLabel.Caption expects UTF-8.
You can use 

label2.Caption:=WinCPToUTF8(c2); // from unit LazUTF8

Maybe SetCaption could check if passed string is not CP_ACP and do a
conversion.

 
Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] How to implement a circular buffer object in pascal?

2020-09-08 Thread vmst--- via fpc-pascal

I would like to create a buffer into which a thread can push incoming
data and the main thread can extract it for processing.
Data are coming from the serial port in a worker thread and should be
consumed by the main thread. The data is a byte stream.

Are there any good examples available?
I have only implemented such systems in C on embedded platforms so it
is not pascal enough to easily port.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Quoted from: 
http://free-pascal-general.1045716.n5.nabble.com/How-to-implement-a-circular-buffer-object-in-pascal-tp5736027.html

Bo,

Send me your email address here

v...@golden.net

Brian


_
Sent from http://free-pascal-general.1045716.n5.nabble.com

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Ethernet Relays

2020-09-08 Thread Michael Van Canneyt via fpc-pascal



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] String literals and code page of .pas source file

2020-09-08 Thread Jonas Maebe via fpc-pascal
On 07/09/2020 08:51, LacaK via fpc-pascal wrote:

> attached simple Lazarus compilable project (one Form).
> 
> ...
> type
>   String1250 = type AnsiString(1250);
> 
> const
>   c2: AnsiString = 'áéíóčž';
>   c3: WideString = 'áéíóčž';
>   c4: String1250 = 'áéíóčž';
> 
> { TForm1 }
> 
> procedure TForm1.FormShow(Sender: TObject);
> begin
>   label1.Caption:='áéíóčž'; // FAIL
>   label2.Caption:=c2;   // FAIL
>   label3.Caption:=c3;   // OK
>   label4.Caption:=c4;   // FAIL
> end;

The attached pure FPC-variant of your project works fine with FPC 3.2.0
for me (except for the very first writeln, because that one gets
interpreted as "writeln(shortstring)"), so it may be Lazarus-specific.
Best ask it on the Lazarus list or post it on their bug tracker instead.

Also make sure you did *not* build your Lazarus with -dDisableUTF8RTL


Jonas
{$IFDEF FPC}
  {$mode objfpc}
  {$h+}
  {$CODEPAGE cp1250}
{$ENDIF}
{$H+}

{$ifdef unix}
uses
  cwstring;
{$endif}
type
  String1250 = type AnsiString(1250);

const
  c2: AnsiString = 'áéíóèž';
  c3: WideString = 'áéíóèž';
  c4: String1250 = 'áéíóèž';

var
  r: rawbytestring;
  s: ansistring;
begin
  DefaultSystemCodePage:=cp_utf8;
  writeln('áéíóèž');
  writeln(c2);
  writeln(c3);
  writeln(c4);
  r:='áéíóèž';
  writeln(r);
  r:=c2;
  writeln(r);
  r:=c3;
  writeln(r);
  r:=c4;
  writeln(r);
  s:='áéíóèž';
  writeln(s);
  s:=c2;
  writeln(s);
  s:=c3;
  writeln(s);
  s:=c4;
  writeln(s);
end.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to implement a circular buffer object in pascal?

2020-09-08 Thread Brian via fpc-pascal
>Bo,
>
>Most of the users on this forum have never interfaced with hardware , as
you
>can see from the responses. Those who have interfaced with hardware have
>developed circular buffers which they  know work , and they reuse them
again
>and again.

I did this about 10 years ago when working on a PIC project with
serial data coming in from sensors and such, using Ansi-C.
And the buffer was just an array of char (byte in pascal) and there
was a read and a write index. The read index was only ever changed by
the consumer and the write index by the interrupt routine when adding
data.

The data reception was done in the interrupt and the code stuffed the
data into the array using ++ syntax for the index, with a check for
overflowing the array and then setting the index back to zero.

There was probably also an overrun detection and action if the
consumer is not fast enough, but I do not remember now...

>
>The following assumes you are receiving data from a sender , and in this
>case the sender and receiver are connected via 1Gbps Ethernet using Synapse
>(works really well).
>
>
>A thread receives data into an array of byte. RxBuffer : Array[0..1500] of
>byte  ... and copies the number of bytes received into a circular buffer ,
>which is an array of RxBuffer.

This is where I lose you, are you saying the circular buffer is not
individual bytes but something larger? What is the size of RxBuffer?
Looks like it is an array of byte, can you then make an array of such
arrays?

 ... The CicBuffer is an array of N RxBuffer , which is an array of byte.
The main loop extracts the byte array and either decodes them or type casts
them into a record structure if it is compatible with the contents of the
byte array,

Type
 RxBufferType = array[0..1500] of byte;

Var
 CirBuffer : array[0..N] of RxBufferType;

>
>In pseudo code it looks like this ...
>CircularBuffer : Array[0..N] of RxBuffer
>There is a ReadIndex and a WriteIndex , both longword or longint.
>
>The thread moves the data into the circular buffer continuously  increase
>the WriteIndex each write of RxBuffer data. If the WriteIndex > N then
>WriteIndex := 0 , otherwise it is increased by 1.
>
>The main loop (below)  moves the byte data using MOVE from CircBuffer to
>whatever structure it represents , increase the ReadIndex by one and
decodes
>the data as needed.

Looks like an array of some bigger datatype then. But if so then one
needs to be able to detect in the receiver that enough data has
arrived to make one such object to put onto the next buffer...

... you appear to be thinking of a asynchronous serial (RS-232 / 422) with
no delimiters to indicate when a complete message is received.

... think of the byte array as an Ethernet packet of any length data of
which the data structure is known. This is received using Synapse (UDP in
this case) and copied into RxBuffer byte array by a thread which is always
running until the main program is shut down. Whenever the thread receives a
"complete" packet from Synapse (it signals a complete packket) , the thread
code  then puts it into RxBuffer and then copies RxBuffer into
CircBuffer[WriteIndex] and increments the WriteIndex. If the WriteIndex < N
then WriteIndex := WriteIndex +1 else WriteIndex := 0 // wraps

The ReadIndex is incremented similar to the WriteIndex, if ReadIndex < N
then ReadIndex := ReadIndex +1 else ReadIndex := 0;

The circular buffer can be made as large as you need to "absorb" incoming
data while the main loop is busy doing something else. The "nice" aspect of
a circular buffer is that if the main loop is very slow and the incoming
data stream is very fast , the WriteIndex will eventually overrun the
ReadIndex and data is lost but nothing chokes or crashes , and eventually
the ReadIndex will catch up.

BTW : There are enough things that can go wrong implementing a circular
buffer , and while it should be possible (and very nice) to implement it as
an object , it may not be worth the effort. At least get it working as
non-object code , then decide.

>
> If ReadIndex <> WriteIndex then
>  .. do the work as described above and increment the ReadIndex
>
>I use the Free Pascal unit which allows suspending the thread while the
>ReadIndex is being increased. In the old DOS/DPMI days we would disable
>interrupts briefly.

Do you use CriticalSection for this?
No . .. I started to originally but found it wasn't necessary as it uses a
semaphore to prevent a Write occurring when the ReadIndex is being
incremented. The FPC unit syncobjs is used the create a semaphore which is
RESET before incrementing the ReadIndex and SET immediately after. This
prevents a potential race condition where data could be written to
CircBuffer at the exact time the ReadIndex is being incremented.

>If you are innterested I can send you code snippets showing exactly how to
>implement the circular buffer.
>

BTW : The circular buffer approach can also be used when transmitting data.
For example Synapse maintains its own transmit 

Re: [fpc-pascal] How to build for arm6 in RaspberryPi on arm7?

2020-09-08 Thread Jonas Maebe via fpc-pascal
On 08/09/2020 16:13, Bo Berglund via fpc-pascal wrote:
> This happened also after I ran a Run/CleanUpAndBuild operation, so
> clearly there is something I am missing here.

Is your FPC installation itself also built for ARMv6? (rtl and packages)


Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFPObjectlist example

2020-09-08 Thread James Richters via fpc-pascal
What’s the difference between TList and TFPGList?  Which one is better for this 
example?
 
James
 
From: fpc-pascal  On Behalf Of Vojtech 
Cihák via fpc-pascal
Sent: Tuesday, September 8, 2020 10:29 AM
To: FPC-Pascal users discussions 
Cc: Vojtěch Čihák 
Subject: Re: [fpc-pascal] TFPObjectlist example
 
Hi,
 
some crippled formatting, so again:
 
However, in your case (records) I would rather use TFPGList from FGL unit:
 
1) add {$modeswitch ADVANCEDRECORDS}
 
2) add FGL to uses
 
3) define class operator =
 
test = record
Port :String;
Size :Byte;
Status :Word;
class operator = (A,B: test): Boolean;
  End; 
4) implement it
class operator test.=(A, B: test): Boolean;
begin
  Result:=(A.Port=B.Port) and (A.Size=B.Size);  // and ...
end;   
5) define specialized list:
 
  TMyL = specialize TFPGList;
 
6) create it
 
  MyList: TMyL;
 
  ...
 
  MyList:=TMyL.Create;
 
Now you can work with it comfortably
 
MyList[1].Port:='abc';
 
V.
__
> Od: "Vojtěch Čihák via fpc-pascal"   >
> Komu: ja...@productionautomation.net  
> , "FPC-Pascal users discussions"   >
> Datum: 08.09.2020 16:21
> Předmět: Re: [fpc-pascal] TFPObjectlist example
>
__
> Od: "James Richters via fpc-pascal"   >
> Komu: "'FPC-Pascal users discussions'"   >
> Datum: 07.09.2020 01:08
> Předmět: [fpc-pascal] TFPObjectlist example
>

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] Help with TList example

2020-09-08 Thread James Richters via fpc-pascal
Thank you for the help, I'll give it a try!

James

-Original Message-
From: fpc-pascal  On Behalf Of Jean 
SUZINEAU via fpc-pascal
Sent: Tuesday, September 8, 2020 8:47 AM
To: fpc-pascal@lists.freepascal.org
Cc: Jean SUZINEAU 
Subject: Re: [fpc-pascal] Help with TList example

Another way is to declare TMyRec as class instead of record.

In this case, you don't need the  dereference operator ^ .

No need of new and dispose, just Create and Free, as for TMyRecList.

I don't know if there is a better performance when you use a record, but as far 
as I know, record/object/new/dispose is just the old syntax for the first 
object oriented programming born with Turbo Pascal 5.5 around 1989.

The new syntax with class / constructor Create / destructor Free is born Delphi 
1 around 1995.

Below is your code modified with TMyRec=class

==

program Project1;
{$mode objfpc}{$H+}

uses
   SysUtils, Classes;

type
   TMyRec=class
 Value: Integer;
 AByte: Byte;
   end;

   TMyRecList=class(TList)
   private
 function Get(Index: Integer): TMyRec;
   public
 destructor Destroy; override;
 function Add(Value: TMyRec): Integer;
 property Items[Index: Integer]: TMyRec read Get; default;
   end;

{ TMyRecList }

function TMyRecList.Add(Value: TMyRec): Integer; begin
   Result := inherited Add(Value);
end;

destructor TMyRecList.Destroy;
var
   i: Integer;
begin
   for i := 0 to Count - 1 do
 Items[i].Free;
   inherited;
end;

function TMyRecList.Get(Index: Integer): TMyRec; begin
   Result := TMyRec(inherited Get(Index)); end;

var
   MyRecList: TMyRecList;
   MyRec: TMyRec;
   tmp: Integer;
begin
   MyRecList := TMyRecList.Create;
   for tmp := 0 to 9 do
   begin
 MyRec:= TMyRec.Create;
 MyRec.Value := tmp;
 MyRec.AByte := Byte(tmp);
 MyRecList.Add(MyRec);
   end;

   for tmp := 0 to MyRecList.Count - 1 do
 Writeln('Value: ', MyRecList[tmp].Value, ' AByte: ', MyRecList[tmp].AByte);
   WriteLn('  Press Enter to free the list');
   ReadLn;
   MyRecList.Free;
end.

___
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

2020-09-08 Thread James Richters via fpc-pascal
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] How to implement a circular buffer object in pascal?

2020-09-08 Thread Bo Berglund via fpc-pascal
On Mon, 7 Sep 2020 14:45:31 -0700 (MST), Brian via fpc-pascal
 wrote:

>Bo,
>
>Most of the users on this forum have never interfaced with hardware , as you
>can see from the responses. Those who have interfaced with hardware have
>developed circular buffers which they  know work , and they reuse them again
>and again.

I did this about 10 years ago when working on a PIC project with
serial data coming in from sensors and such, using Ansi-C.
And the buffer was just an array of char (byte in pascal) and there
was a read and a write index. The read index was only ever changed by
the consumer and the write index by the interrupt routine when adding
data.

The data reception was done in the interrupt and the code stuffed the
data into the array using ++ syntax for the index, with a check for
overflowing the array and then setting the index back to zero.

There was probably also an overrun detection and action if the
consumer is not fast enough, but I do not remember now...

>
>The following assumes you are receiving data from a sender , and in this
>case the sender and receiver are connected via 1Gbps Ethernet using Synapse
>(works really well).
>
>
>A thread receives data into an array of byte. RxBuffer : Array[0..1500] of
>byte  ... and copies the number of bytes received into a circular buffer ,
>which is an array of RxBuffer.

This is where I lose you, are you saying the circular buffer is not
individual bytes but something larger? What is the size of RxBuffer?
Looks like it is an array of byte, can you then make an array of such
arrays?

>
>In pseudo code it looks like this ...
>CircularBuffer : Array[0..N] of RxBuffer
>There is a ReadIndex and a WriteIndex , both longword or longint.
>
>The thread moves the data into the circular buffer continuously  increase
>the WriteIndex each write of RxBuffer data. If the WriteIndex > N then
>WriteIndex := 0 , otherwise it is increased by 1.
>
>The main loop (below)  moves the byte data using MOVE from CircBuffer to
>whatever structure it represents , increase the ReadIndex by one and decodes
>the data as needed.

Looks like an array of some bigger datatype then. But if so then one
needs to be able to detect in the receiver that enough data has
arrived to make one such object to put onto the next buffer...

>
> If ReadIndex <> WriteIndex then
>  .. do the work as described above and increment the ReadIndex
>
>I use the Free Pascal unit which allows suspending the thread while the
>ReadIndex is being increased. In the old DOS/DPMI days we would disable
>interrupts briefly.

Do you use CriticalSection for this?

>If you are innterested I can send you code snippets showing exactly how to
>implement the circular buffer.
>

Please do, thanks!

-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFPObjectlist example

2020-09-08 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
some crippled formatting, so again:
 
However, in your case (records) I would rather use TFPGList from FGL unit:
 
1) add {$modeswitch ADVANCEDRECORDS}
 
2) add FGL to uses
3) define class operator =
test = record    Port :String;    Size :Byte;    Status :Word;    class 
operator = (A,B: test): Boolean;  End; 4) implement itclass operator test.=(A, 
B: test): Boolean;begin  Result:=(A.Port=B.Port) and (A.Size=B.Size);  // and 
...end;   5) define specialized list:
 
  TMyL = specialize TFPGList;
 
6) create it
 
  MyList: TMyL;
 
  ...
 
  MyList:=TMyL.Create;
 
Now you can work with it comfortably
 
MyList[1].Port:='abc';
 
V.
__

Od: "Vojtěch Čihák via fpc-pascal" 
Komu: ja...@productionautomation.net, "FPC-Pascal users discussions" 

Datum: 08.09.2020 16:21
Předmět: Re: [fpc-pascal] TFPObjectlist example


__
> Od: "James Richters via fpc-pascal" 
> Komu: "'FPC-Pascal users discussions'" 
> Datum: 07.09.2020 01:08
> Předmět: [fpc-pascal] TFPObjectlist example
>

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] Help with TList example

2020-09-08 Thread Ryan Joseph via fpc-pascal


> On Sep 8, 2020, at 6:10 PM, James Richters via fpc-pascal 
>  wrote:
> 
> I'm trying to figure out how TList works.  I found the code example below by 
> doing a search, but I can't compile it,  I get Error: Illegal qualifier on 
> the line  

Do you want an array of pointers (objects allocated on the stack) or an array 
of records (i.e. one continuous block of memory? I you want an array of 
pointers try using classes as mentioned or if you want an array of records try 
TFPGList and specialize for your record type.

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFPObjectlist example

2020-09-08 Thread Vojtěch Čihák via fpc-pascal

Hi,
 
I used TFPObjectList only once, for visual component TECAccordion 
(https://wiki.lazarus.freepascal.org/Eye-Candy_Controls#TECAccordion). Each 
item of list is derived from TWinControl so it is possible to use it even for 
visual components (like TCollection).
 
However, in your case (records) I would rather use TFPGList from FGL unit:
 
1) add {$modeswitch ADVANCEDRECORDS}
2) add FGL to uses3) define class operator =test = record    Port :String;    
Size :Byte;    Status :Word;    class operator = (A,B: test): Boolean;  End; 4) 
implement itclass operator test.=(A, B: test): Boolean;begin  
Result:=(A.Port=B.Port) and (A.Size=B.Size);  // and ...end;   5) define 
specialized list:
  TMyL = specialize TFPGList;
6) create it
  MyList: TMyL;
  ...
  MyList:=TMyL.Create;
 
Now you can work with it comfortably
MyList[1].Port:='abc';
 
V.
__

Od: "James Richters via fpc-pascal" 
Komu: "'FPC-Pascal users discussions'" 
Datum: 07.09.2020 01:08
Předmět: [fpc-pascal] TFPObjectlist example



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


Re: [fpc-pascal] How to build for arm6 in RaspberryPi on arm7?

2020-09-08 Thread Bo Berglund via fpc-pascal
On Tue, 08 Sep 2020 15:11:07 +0200, Bo Berglund via fpc-pascal
 wrote:

>Is there some project setting I can activate in order to build for
>*all* RPi devices by only using ARMv6 instructions?

I used Project/ProjectOptions/ConfigAndTarget and:
set Target CPU family = arm
set Target processor = ARMV6

The project built fine on an RPi4B with 4GB RAM
And it ran just fine on the dev RPi4

So I used scp to copy the executable over to an RPiZero and test it
there.

But I got an exception on this platform:

pi@rpizero:~/Downloads $ ./SerialTest 
An unhandled exception occurred at $00031C44:
EAccessViolation: Access violation
  $00031C44

This happened also after I ran a Run/CleanUpAndBuild operation, so
clearly there is something I am missing here.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] How to build for arm6 in RaspberryPi on arm7?

2020-09-08 Thread Bo Berglund via fpc-pascal
I am using RPi3 and RPi4 platforms when working on RPi projects with
Lazarus 2.0.8 and Fpc 3.0.4.
Now I realized that the binaries I create will probably not work on
PiZero and RPi2 devices because these are Arm6 and the dev platform is
Arm7.

Is there some project setting I can activate in order to build for
*all* RPi devices by only using ARMv6 instructions?

I really do not want to work in the IDE on a PiZero or Pi2 because
these are a bit slow...


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Help with TList example

2020-09-08 Thread Jean SUZINEAU via fpc-pascal

Another way is to declare TMyRec as class instead of record.

In this case, you don't need the  dereference operator ^ .

No need of new and dispose, just Create and Free, as for TMyRecList.

I don't know if there is a better performance when you use a record,
but as far as I know, record/object/new/dispose is just the old syntax 
for the first object oriented programming born with Turbo Pascal 5.5 
around 1989.


The new syntax with class / constructor Create / destructor Free is born 
Delphi 1 around 1995.


Below is your code modified with TMyRec=class

==

program Project1;
{$mode objfpc}{$H+}

uses
  SysUtils, Classes;

type
  TMyRec=class
    Value: Integer;
    AByte: Byte;
  end;

  TMyRecList=class(TList)
  private
    function Get(Index: Integer): TMyRec;
  public
    destructor Destroy; override;
    function Add(Value: TMyRec): Integer;
    property Items[Index: Integer]: TMyRec read Get; default;
  end;

{ TMyRecList }

function TMyRecList.Add(Value: TMyRec): Integer;
begin
  Result := inherited Add(Value);
end;

destructor TMyRecList.Destroy;
var
  i: Integer;
begin
  for i := 0 to Count - 1 do
    Items[i].Free;
  inherited;
end;

function TMyRecList.Get(Index: Integer): TMyRec;
begin
  Result := TMyRec(inherited Get(Index));
end;

var
  MyRecList: TMyRecList;
  MyRec: TMyRec;
  tmp: Integer;
begin
  MyRecList := TMyRecList.Create;
  for tmp := 0 to 9 do
  begin
    MyRec:= TMyRec.Create;
    MyRec.Value := tmp;
    MyRec.AByte := Byte(tmp);
    MyRecList.Add(MyRec);
  end;

  for tmp := 0 to MyRecList.Count - 1 do
    Writeln('Value: ', MyRecList[tmp].Value, ' AByte: ', 
MyRecList[tmp].AByte);

  WriteLn('  Press Enter to free the list');
  ReadLn;
  MyRecList.Free;
end.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Help with TList example

2020-09-08 Thread Tony Whyman via fpc-pascal

See https://www.freepascal.org/docs-html/rtl/system/dispose.html

On 08/09/2020 12:51, James Richters wrote:

Can you please give me an example of the correct way to use new and dispose?

I'll try the pointer

Thanks for the advice

James

-Original Message-
From: fpc-pascal  On Behalf Of Tony 
Whyman via fpc-pascal
Sent: Tuesday, September 8, 2020 7:21 AM
To: fpc-pascal@lists.freepascal.org
Cc: Tony Whyman 
Subject: Re: [fpc-pascal] Help with TList example

Two observations:

1. In Pascal you should use "new" and "dispose" to allocate and deallocate 
record types - not GetMem and FreeMem.

2. MyRec is a pointer type and you should code the line as

MyRec^.Value := tmp


On 08/09/2020 12:10, James Richters via fpc-pascal wrote:

I'm trying to figure out how TList works.  I found the code example below by 
doing a search, but I can't compile it,  I get Error: Illegal qualifier on the 
line
  MyRec.Value := tmp;
It's indicating the error is on the V of Value

I tried commenting that line out, then I get the same error on
  MyRec.AByte := Byte(tmp);
At the A of AByte

So I commented that out too and then I get the error on

 Writeln('Value: ', MyRecList[tmp].Value, ' AByte: ',
MyRecList[tmp].AByte); At the V on Value after MyRecList[tmp].

I don't know enough about the syntax to figure out what's wrong here.  Does 
anyone have any ideas?  It seems like there is something fundamentally wrong.

I'm trying to make a temporary list of records.  Kind of like a TStringList, 
but instead of a list of strings, a list of my own custom records.  Perhaps 
there is a better way?


program Project1;
{$mode objfpc}{$H+}

uses
SysUtils, Classes;

type
PMyRec=^TMyRec;
TMyRec=record
  Value: Integer;
  AByte: Byte;
end;

TMyRecList=class(TList)
private
  function Get(Index: Integer): PMyRec;
public
  destructor Destroy; override;
  function Add(Value: PMyRec): Integer;
  property Items[Index: Integer]: PMyRec read Get; default;
end;

{ TMyRecList }

function TMyRecList.Add(Value: PMyRec): Integer; begin
Result := inherited Add(Value);
end;

destructor TMyRecList.Destroy;
var
i: Integer;
begin
for i := 0 to Count - 1 do
  FreeMem(Items[i]);
inherited;
end;

function TMyRecList.Get(Index: Integer): PMyRec; begin
Result := PMyRec(inherited Get(Index)); end;

var
MyRecList: TMyRecList;
MyRec: pMyRec;
tmp: Integer;
begin
MyRecList := TMyRecList.Create;
for tmp := 0 to 9 do
begin
  GetMem(MyRec, SizeOf(TMyRec));
  MyRec.Value := tmp;
  MyRec.AByte := Byte(tmp);
  MyRecList.Add(MyRec);
end;

for tmp := 0 to MyRecList.Count - 1 do
  Writeln('Value: ', MyRecList[tmp].Value, ' AByte: ', 
MyRecList[tmp].AByte);
WriteLn('  Press Enter to free the list');
ReadLn;
MyRecList.Free;
end.

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] Help with TList example

2020-09-08 Thread James Richters via fpc-pascal
Can you please give me an example of the correct way to use new and dispose?

I'll try the pointer

Thanks for the advice

James

-Original Message-
From: fpc-pascal  On Behalf Of Tony 
Whyman via fpc-pascal
Sent: Tuesday, September 8, 2020 7:21 AM
To: fpc-pascal@lists.freepascal.org
Cc: Tony Whyman 
Subject: Re: [fpc-pascal] Help with TList example

Two observations:

1. In Pascal you should use "new" and "dispose" to allocate and deallocate 
record types - not GetMem and FreeMem.

2. MyRec is a pointer type and you should code the line as

MyRec^.Value := tmp


On 08/09/2020 12:10, James Richters via fpc-pascal wrote:
> I'm trying to figure out how TList works.  I found the code example below by 
> doing a search, but I can't compile it,  I get Error: Illegal qualifier on 
> the line
>  MyRec.Value := tmp;
>It's indicating the error is on the V of Value
>
> I tried commenting that line out, then I get the same error on
>  MyRec.AByte := Byte(tmp);
> At the A of AByte
>
> So I commented that out too and then I get the error on
>
> Writeln('Value: ', MyRecList[tmp].Value, ' AByte: ', 
> MyRecList[tmp].AByte); At the V on Value after MyRecList[tmp].
>
> I don't know enough about the syntax to figure out what's wrong here.  Does 
> anyone have any ideas?  It seems like there is something fundamentally wrong.
>
> I'm trying to make a temporary list of records.  Kind of like a TStringList, 
> but instead of a list of strings, a list of my own custom records.  Perhaps 
> there is a better way?
>
>
> program Project1;
> {$mode objfpc}{$H+}
>
> uses
>SysUtils, Classes;
>
> type
>PMyRec=^TMyRec;
>TMyRec=record
>  Value: Integer;
>  AByte: Byte;
>end;
>
>TMyRecList=class(TList)
>private
>  function Get(Index: Integer): PMyRec;
>public
>  destructor Destroy; override;
>  function Add(Value: PMyRec): Integer;
>  property Items[Index: Integer]: PMyRec read Get; default;
>end;
>
> { TMyRecList }
>
> function TMyRecList.Add(Value: PMyRec): Integer; begin
>Result := inherited Add(Value);
> end;
>
> destructor TMyRecList.Destroy;
> var
>i: Integer;
> begin
>for i := 0 to Count - 1 do
>  FreeMem(Items[i]);
>inherited;
> end;
>
> function TMyRecList.Get(Index: Integer): PMyRec; begin
>Result := PMyRec(inherited Get(Index)); end;
>
> var
>MyRecList: TMyRecList;
>MyRec: pMyRec;
>tmp: Integer;
> begin
>MyRecList := TMyRecList.Create;
>for tmp := 0 to 9 do
>begin
>  GetMem(MyRec, SizeOf(TMyRec));
>  MyRec.Value := tmp;
>  MyRec.AByte := Byte(tmp);
>  MyRecList.Add(MyRec);
>end;
>
>for tmp := 0 to MyRecList.Count - 1 do
>  Writeln('Value: ', MyRecList[tmp].Value, ' AByte: ', 
> MyRecList[tmp].AByte);
>WriteLn('  Press Enter to free the list');
>ReadLn;
>MyRecList.Free;
> end.
>
> 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

2020-09-08 Thread Michael Van Canneyt via fpc-pascal




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] Help with TList example

2020-09-08 Thread Tony Whyman via fpc-pascal

Two observations:

1. In Pascal you should use "new" and "dispose" to allocate and 
deallocate record types - not GetMem and FreeMem.


2. MyRec is a pointer type and you should code the line as

MyRec^.Value := tmp


On 08/09/2020 12:10, James Richters via fpc-pascal wrote:

I'm trying to figure out how TList works.  I found the code example below by 
doing a search, but I can't compile it,  I get Error: Illegal qualifier on the 
line
 MyRec.Value := tmp;
   It's indicating the error is on the V of Value

I tried commenting that line out, then I get the same error on
 MyRec.AByte := Byte(tmp);
At the A of AByte

So I commented that out too and then I get the error on

Writeln('Value: ', MyRecList[tmp].Value, ' AByte: ', MyRecList[tmp].AByte);
At the V on Value after MyRecList[tmp].

I don't know enough about the syntax to figure out what's wrong here.  Does 
anyone have any ideas?  It seems like there is something fundamentally wrong.

I'm trying to make a temporary list of records.  Kind of like a TStringList, 
but instead of a list of strings, a list of my own custom records.  Perhaps 
there is a better way?


program Project1;
{$mode objfpc}{$H+}

uses
   SysUtils, Classes;

type
   PMyRec=^TMyRec;
   TMyRec=record
 Value: Integer;
 AByte: Byte;
   end;

   TMyRecList=class(TList)
   private
 function Get(Index: Integer): PMyRec;
   public
 destructor Destroy; override;
 function Add(Value: PMyRec): Integer;
 property Items[Index: Integer]: PMyRec read Get; default;
   end;

{ TMyRecList }

function TMyRecList.Add(Value: PMyRec): Integer;
begin
   Result := inherited Add(Value);
end;

destructor TMyRecList.Destroy;
var
   i: Integer;
begin
   for i := 0 to Count - 1 do
 FreeMem(Items[i]);
   inherited;
end;

function TMyRecList.Get(Index: Integer): PMyRec;
begin
   Result := PMyRec(inherited Get(Index));
end;

var
   MyRecList: TMyRecList;
   MyRec: pMyRec;
   tmp: Integer;
begin
   MyRecList := TMyRecList.Create;
   for tmp := 0 to 9 do
   begin
 GetMem(MyRec, SizeOf(TMyRec));
 MyRec.Value := tmp;
 MyRec.AByte := Byte(tmp);
 MyRecList.Add(MyRec);
   end;

   for tmp := 0 to MyRecList.Count - 1 do
 Writeln('Value: ', MyRecList[tmp].Value, ' AByte: ', MyRecList[tmp].AByte);
   WriteLn('  Press Enter to free the list');
   ReadLn;
   MyRecList.Free;
end.

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] Help with TList example

2020-09-08 Thread James Richters via fpc-pascal
I'm trying to figure out how TList works.  I found the code example below by 
doing a search, but I can't compile it,  I get Error: Illegal qualifier on the 
line  
MyRec.Value := tmp;
  It's indicating the error is on the V of Value

I tried commenting that line out, then I get the same error on
MyRec.AByte := Byte(tmp);
At the A of AByte

So I commented that out too and then I get the error on 

   Writeln('Value: ', MyRecList[tmp].Value, ' AByte: ', MyRecList[tmp].AByte); 
At the V on Value after MyRecList[tmp].

I don't know enough about the syntax to figure out what's wrong here.  Does 
anyone have any ideas?  It seems like there is something fundamentally wrong.

I'm trying to make a temporary list of records.  Kind of like a TStringList, 
but instead of a list of strings, a list of my own custom records.  Perhaps 
there is a better way?


program Project1;
{$mode objfpc}{$H+}

uses
  SysUtils, Classes;

type
  PMyRec=^TMyRec;
  TMyRec=record
Value: Integer;
AByte: Byte;
  end;

  TMyRecList=class(TList)
  private
function Get(Index: Integer): PMyRec;
  public
destructor Destroy; override;
function Add(Value: PMyRec): Integer;
property Items[Index: Integer]: PMyRec read Get; default;
  end;

{ TMyRecList }

function TMyRecList.Add(Value: PMyRec): Integer;
begin
  Result := inherited Add(Value);
end;

destructor TMyRecList.Destroy;
var
  i: Integer;
begin
  for i := 0 to Count - 1 do
FreeMem(Items[i]);
  inherited;
end;

function TMyRecList.Get(Index: Integer): PMyRec;
begin
  Result := PMyRec(inherited Get(Index));
end;

var
  MyRecList: TMyRecList;
  MyRec: pMyRec;
  tmp: Integer;
begin
  MyRecList := TMyRecList.Create;
  for tmp := 0 to 9 do
  begin
GetMem(MyRec, SizeOf(TMyRec));
MyRec.Value := tmp;
MyRec.AByte := Byte(tmp);
MyRecList.Add(MyRec);
  end;

  for tmp := 0 to MyRecList.Count - 1 do
Writeln('Value: ', MyRecList[tmp].Value, ' AByte: ', MyRecList[tmp].AByte);
  WriteLn('  Press Enter to free the list');
  ReadLn;
  MyRecList.Free;
end.

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Ethernet Relays

2020-09-08 Thread James Richters via fpc-pascal
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

2020-09-08 Thread Michael Van Canneyt via fpc-pascal


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] Why can I not build fpc 3.0.4 with ppcarm 3.0.0 or 3.0.4?

2020-09-08 Thread Bo Berglund via fpc-pascal
On Tue, 08 Sep 2020 00:59:51 +0200, Bo Berglund via fpc-pascal
 wrote:

>Today when I was setting up a Raspberry PiZero I was hit with this
>message when I was going to build fpc 3.0.4 (sources checked out from
>svn):
>
>Makefile:2790: *** The only supported starting compiler version is
>3.0.2. You are trying to build with ..  Stop.
>

It turns out that this was a grossly misleading error message!
The real problem was that the RPiZero is arm v6 and the seed compiler
downloaded was arm v7!

After changing to ppcarm 3.0.0 for arm6 the build works.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal