[Lazarus] How many timers available on Linux (Raspberry Pi)?

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
I have ported a Delphi service application from Windows to a console
application on Linux.
I am using Lazarus 2.0.8/Fpc 3.0.4 on Raspbian Buster on an RPi4B.

Today I finally could start it the first time and it immediately threw
an exception with this printed to the console:

pi@rpi4-gui:~/projects/SSRemoteServer/source $ ./SSRemoteServerLx
[FORMS.PP] ExceptionOccurred
  Sender=EOutOfResources
  Exception=No timers available
  Stack trace:
  $0025DB18  TCUSTOMTIMER__UPDATETIMER,  line 131 of customtimer.pas
  $0025DC40  TCUSTOMTIMER__SETONTIMER,  line 165 of customtimer.pas
  $00088ABC  TSSREMOTESERVER__CREATE,  line 553 of
class_SSRemoteServer.pas
  $00010B14  CREATEOBJECTS,  line 62 of SSRemoteServerLx.lpr
  $00010CF4  main,  line 114 of SSRemoteServerLx.lpr
Exception at 0025DB18: EOutOfResources:
No timers available.

The exception happens at the very start of the application when
creating the objects which will run the show.
Line 553 of the unit where the problem occurs is marked below with =>

Up until then 3 timers have been successfully created and then the
exception happens when the 4th timer gets its OnTimer event defined...
"No timers available." indicates a possible limit to the number of
timers????

So now I wonder if there is a limit on the number of timers available
on Linux (since this works on Windows)???

Code section where exception happens:

constructor TSSRemoteServer.Create(AOwner: TObject);
begin
  FOwner := AOwner;
  FSSConnection := TSSConnection.Create;
  FSSConnection.OnMessage := OnSSMessage;
  FSSConnection.OnRemoteReadingDone := OnRemoteReadingDone;
  FSSConnection.OnContactResTestDone := OnContactResTestDone;

  FCurrentCmdFile := TSSCommandFile.Create;
  FCurrentMeasureFile := TSSMeasureFile.Create;

  FTasks := TObjectList.Create;  {List of scheduled tasks}
  FTasks.OwnsObjects := true;

  FNormalUsers := TStringList.Create;

  FTimExecute := TTimer.Create(NIL);
  FTimExecute.Enabled := false;
  FTimExecute.Interval := 250;  {Just the start delay}
  FTimExecute.OnTimer := OnExecuteTimer;

  FTimSchedule := TTimer.Create(NIL);
  FTimSchedule.Enabled := false;
  FTimSchedule.Interval := 1000;  {Should be configurable...}
  FTimSchedule.OnTimer := OnScheduleTimer;

  FTimWaitForMeasure := TTimer.Create(NIL);
  FTimWaitForMeasure.Enabled := false;
  FTimWaitForMeasure.Interval := 150;  {Should be configurable...}
  FTimWaitForMeasure.OnTimer := OnWaitForMeasureTimer;

  FTimCmdQueue := TTimer.Create(NIL);
  FTimCmdQueue.Interval := 35;
=>FTimCmdQueue.OnTimer := OnCmdQueueTimer;
  FTimCmdQueue.Enabled := true;


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
On gtk2 it calls TGtk2WidgetSet.CreateTimer, which calls gtk_timeout_add()
I cannot find in inet, about max number of 'timeouts' in gtk2.

Alexey

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
On Wed, 22 Jul 2020 08:09:08 +0300, "Alexey Tor. via lazarus"
<[hidden email]> wrote:

>On gtk2 it calls TGtk2WidgetSet.CreateTimer, which calls gtk_timeout_add()
>I cannot find in inet, about max number of 'timeouts' in gtk2.
>
>Alexey

I am using:
LCLWidgetType:=nogui

This is a console program, which I guess I should have stated in my
thread subject...

It is intended to be run as a systemd service once done.
Until then I test it using a terminal.


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list


On Wed, 22 Jul 2020, Bo Berglund via lazarus wrote:

> On Wed, 22 Jul 2020 08:09:08 +0300, "Alexey Tor. via lazarus"
> <[hidden email]> wrote:
>
>> On gtk2 it calls TGtk2WidgetSet.CreateTimer, which calls gtk_timeout_add()
>> I cannot find in inet, about max number of 'timeouts' in gtk2.
>>
>> Alexey
>
> I am using:
> LCLWidgetType:=nogui
>
> This is a console program, which I guess I should have stated in my
> thread subject...

The NoGUI widgetset does not support timers:

function TNoGUIWidgetSet.CreateTimer(Interval: integer; TimerFunc: TWSTimerProc
   ): THandle;
begin
   Result:=0;
end;

function TNoGUIWidgetSet.DestroyTimer(TimerHandle: THandle): boolean;
begin
   Result:=false;
end;

As I stated many times before: DO NOT use the nogui widgetset.
It is a basically flawed concept.

Create a normal console appliation instead and use the fpTimer unit if you
need a timer.

Michael.

PS.
Please change the lazarus mailing list address you use to <[hidden email]>
It seems you're still using the old [hidden email]
People doing a reply and don't pay attention will send the reply twice,
since the [hidden email] is put in CC.

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
On Wed, 22 Jul 2020 11:21:07 +0200 (CEST), Michael Van Canneyt via
lazarus <[hidden email]> wrote:

>PS.
>Please change the lazarus mailing list address you use to <[hidden email]>
>It seems you're still using the old [hidden email]
>People doing a reply and don't pay attention will send the reply twice,
>since the [hidden email] is put in CC.

Well, I am not using my email client to interface to this list,
instead I use the NNTP mirror at news.gmane.io

So my action is to post to the news server and it in turn sends it on
to the mail list...
I don't know how to change how that is being done.


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list


On Wed, 22 Jul 2020, Bo Berglund via lazarus wrote:

> On Wed, 22 Jul 2020 11:21:07 +0200 (CEST), Michael Van Canneyt via
> lazarus <[hidden email]> wrote:
>
>> PS.
>> Please change the lazarus mailing list address you use to <[hidden email]>
>> It seems you're still using the old [hidden email]
>> People doing a reply and don't pay attention will send the reply twice,
>> since the [hidden email] is put in CC.
>
> Well, I am not using my email client to interface to this list,
> instead I use the NNTP mirror at news.gmane.io
>
> So my action is to post to the news server and it in turn sends it on
> to the mail list...
> I don't know how to change how that is being done.

Probably the NNTP mirror is still using the old address in that case.
Unfortunately, I don't know who maintains it...

Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
On 22.07.2020 11:44, Michael Van Canneyt via lazarus wrote:
> Probably the NNTP mirror is still using the old address in that case.
> Unfortunately, I don't know who maintains it...

I do not maintain it, but I requested an email address update for the
lazarus mailing list on https://admin.gmane.io/

Ondrej

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Wed, 22 Jul 2020 11:21:07 +0200 (CEST), Michael Van Canneyt via
lazarus <[hidden email]> wrote:

>
>
>On Wed, 22 Jul 2020, Bo Berglund via lazarus wrote:
>
>> On Wed, 22 Jul 2020 08:09:08 +0300, "Alexey Tor. via lazarus"
>> <[hidden email]> wrote:
>>
>>> On gtk2 it calls TGtk2WidgetSet.CreateTimer, which calls gtk_timeout_add()
>>> I cannot find in inet, about max number of 'timeouts' in gtk2.
>>>
>>> Alexey
>>
>> I am using:
>> LCLWidgetType:=nogui
>>
>> This is a console program, which I guess I should have stated in my
>> thread subject...
>
>The NoGUI widgetset does not support timers:
>
>function TNoGUIWidgetSet.CreateTimer(Interval: integer; TimerFunc: TWSTimerProc
>   ): THandle;
>begin
>   Result:=0;
>end;
>
>function TNoGUIWidgetSet.DestroyTimer(TimerHandle: THandle): boolean;
>begin
>   Result:=false;
>end;
>
>As I stated many times before: DO NOT use the nogui widgetset.
>It is a basically flawed concept.
>
>Create a normal console appliation instead and use the fpTimer unit if you
>need a timer.
>
>Michael.

OK,
so I created this program as a simple program with no template.
In Delphi it was a TService descendant, but now i want it to just be a
normal console program, which I can run as a service under Systemd on
Linux.

Then while chasing a strange error concerning wsmenus I changed from
what it was in the beginning to nogui.

Now I do not know how to cancel that change and get back to what it
was before (it needs to be a console app and dual platform).

There 13 different "widgets" offered and I do not remember what it was
in the beginning. So which do I choose for a dual platform
(Linux/Windows) application?

Concerning timers the old application I am porting makes heavy use of
TTimer objects, there are probably a lot more than the 4 I have in
this constructor.

So I should change the timer class from TTimer to TfpTimer or some
such?

I assume that is cross-platform, right?


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
On Wed, 22 Jul 2020 11:55:27 +0200, Bo Berglund via lazarus
<[hidden email]> wrote:

>Then while chasing a strange error concerning wsmenus I changed from
>what it was in the beginning to nogui.
>
>Now I do not know how to cancel that change and get back to what it
>was before (it needs to be a console app and dual platform).
>
>There 13 different "widgets" offered and I do not remember what it was
>in the beginning. So which do I choose for a dual platform
>(Linux/Windows) application?

Never mind, I created a new project and had a look.
It seems like what I need to do in the dialog is to delete the
widgetset setting...


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list


On Wed, 22 Jul 2020, Bo Berglund via lazarus wrote:

> OK,
> so I created this program as a simple program with no template.
> In Delphi it was a TService descendant, but now i want it to just be a
> normal console program, which I can run as a service under Systemd on
> Linux.
>
> Then while chasing a strange error concerning wsmenus I changed from
> what it was in the beginning to nogui.

It means you have somewhere a reference to a LCL/VCL unit.

Probably your use of TTimer caused this.

>
> Now I do not know how to cancel that change and get back to what it
> was before (it needs to be a console app and dual platform).
>
> There 13 different "widgets" offered and I do not remember what it was
> in the beginning. So which do I choose for a dual platform
> (Linux/Windows) application?

You don't need to set a widget for a console application.

> Concerning timers the old application I am porting makes heavy use of
> TTimer objects, there are probably a lot more than the 4 I have in
> this constructor.
>
> So I should change the timer class from TTimer to TfpTimer or some
> such?
>
> I assume that is cross-platform, right?

Yes.

Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
On Wed, 22 Jul 2020 12:34:34 +0200 (CEST), Michael Van Canneyt via
lazarus <[hidden email]> wrote:

>> Then while chasing a strange error concerning wsmenus I changed from
>> what it was in the beginning to nogui.
>
>It means you have somewhere a reference to a LCL/VCL unit.
>
>Probably your use of TTimer caused this.
>

No, it was caused by package LazSerial...
It brings in a number of units I would not use in any console app like
this:

SysUtils, lazsynaser,  LResources, Forms, Controls, Graphics, Dialogs;

The "solution" (after googling a lot) was to add "interfaces" just
before lazserial in the uses clause of the unit that handles the
serial comm stuff:

  {$IFDEF FPC}
    interfaces, //Needed for LazSerial to work in a Console program
    LazSerial,
  {$ELSE} //Delphi

Then these linker only errors went away (compile phase worked just
fine before I did this).


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Wed, 22 Jul 2020 12:23:42 +0200, Bo Berglund via lazarus
<[hidden email]> wrote:

>On Wed, 22 Jul 2020 11:55:27 +0200, Bo Berglund via lazarus
><[hidden email]> wrote:
>
>>Then while chasing a strange error concerning wsmenus I changed from
>>what it was in the beginning to nogui.
>>
>>Now I do not know how to cancel that change and get back to what it
>>was before (it needs to be a console app and dual platform).
>>
>>There 13 different "widgets" offered and I do not remember what it was
>>in the beginning. So which do I choose for a dual platform
>>(Linux/Windows) application?
>
>Never mind, I created a new project and had a look.
>It seems like what I need to do in the dialog is to delete the
>widgetset setting...
>
And after this was done I could build the app and run it without the
exceptions appearing.

OTOH it does not start the TCP server by the looks of it, but that is
another problem that belongs to the normal tracing of the
functionality.
I wonder if the TTimers are working or if I should change to TfpTimer
as suggested? I cannot tell right now.


Plain troubleshooting remains, which is a bit difficult with console
programs since running from Lazarus does not produce a visible output,
like in Delphi where a terminal like window pops up.

But that is OT for this thread...


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list


On Wed, 22 Jul 2020, Bo Berglund via lazarus wrote:

> On Wed, 22 Jul 2020 12:34:34 +0200 (CEST), Michael Van Canneyt via
> lazarus <[hidden email]> wrote:
>
>>> Then while chasing a strange error concerning wsmenus I changed from
>>> what it was in the beginning to nogui.
>>
>> It means you have somewhere a reference to a LCL/VCL unit.
>>
>> Probably your use of TTimer caused this.
>>
>
> No, it was caused by package LazSerial...
> It brings in a number of units I would not use in any console app like
> this:
>
> SysUtils, lazsynaser,  LResources, Forms, Controls, Graphics, Dialogs;
>
> The "solution" (after googling a lot) was to add "interfaces" just
> before lazserial in the uses clause of the unit that handles the
> serial comm stuff:
>
>  {$IFDEF FPC}
>    interfaces, //Needed for LazSerial to work in a Console program
>    LazSerial,
>  {$ELSE} //Delphi
>
> Then these linker only errors went away (compile phase worked just
> fine before I did this).

The lazserial seems to be a wrapper around lazsynaser, which I assume is from synapse.

You should be OK just using directly lazsynaser.

It has no GUI dependencies. The drawback is probably that you must create
the component in code instead of dropping it on a datamodule.

I would suggest to the maintainers of lazserial to

a) Really clean up the uses clause.
    There is no need for  LResources, Forms, Controls, Graphics, Dialogs in the uses clause.

b) *always* put the registration of a component in a separate unit,
    never in the unit itself. It creates unwanted dependencies.


Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list


On Wed, 22 Jul 2020, Bo Berglund via lazarus wrote:

> On Wed, 22 Jul 2020 12:23:42 +0200, Bo Berglund via lazarus
> <[hidden email]> wrote:
>
>> On Wed, 22 Jul 2020 11:55:27 +0200, Bo Berglund via lazarus
>> <[hidden email]> wrote:
>>
>>> Then while chasing a strange error concerning wsmenus I changed from
>>> what it was in the beginning to nogui.
>>>
>>> Now I do not know how to cancel that change and get back to what it
>>> was before (it needs to be a console app and dual platform).
>>>
>>> There 13 different "widgets" offered and I do not remember what it was
>>> in the beginning. So which do I choose for a dual platform
>>> (Linux/Windows) application?
>>
>> Never mind, I created a new project and had a look.
>> It seems like what I need to do in the dialog is to delete the
>> widgetset setting...
>>
> And after this was done I could build the app and run it without the
> exceptions appearing.
>
> OTOH it does not start the TCP server by the looks of it, but that is
> another problem that belongs to the normal tracing of the
> functionality.
> I wonder if the TTimers are working or if I should change to TfpTimer
> as suggested? I cannot tell right now.

TTimer does not work in nogui or console applications.

Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
On Wed, 22 Jul 2020 13:24:58 +0200 (CEST), Michael Van Canneyt via
lazarus <[hidden email]> wrote:

>> OTOH it does not start the TCP server by the looks of it, but that is
>> another problem that belongs to the normal tracing of the
>> functionality.

That was caused by a missing call to "StartServer"....
It now runs and can be connected to using the old Windows client
application.

>> I wonder if the TTimers are working or if I should change to TfpTimer
>> as suggested? I cannot tell right now.
>
>TTimer does not work in nogui or console applications.
>

That means I will have to go over the code and replace TTimer with the
fpTimer instead.
Something like:

{$IFDEF FPC}
  FCommTimer: TFPTimer;
{$ELSE} //Delphi
  FCommTimer: TTimer;
{$ENDIF}

And also fixing the uses clause the same way.

Thanks for the clarification!


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Wed, 22 Jul 2020 13:23:43 +0200 (CEST), Michael Van Canneyt via
lazarus <[hidden email]> wrote:

>The lazserial seems to be a wrapper around lazsynaser, which I assume is from synapse.
>
>You should be OK just using directly lazsynaser.
>
>It has no GUI dependencies. The drawback is probably that you must create
>the component in code instead of dropping it on a datamodule.

I am anyway creating everything in code in a console application...

The reason I went with LazSerial is that it was the closest in
functionality I could find to the serial port component I used in the
source Delphi program I am porting.

For example I need the event model for retrieving the incoming data
and the transmit must not be blocking.


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How many timers available on Linux (Raspberry Pi)?

Free Pascal - Lazarus mailing list


On Thu, 23 Jul 2020, Bo Berglund via lazarus wrote:

> On Wed, 22 Jul 2020 13:23:43 +0200 (CEST), Michael Van Canneyt via
> lazarus <[hidden email]> wrote:
>
>> The lazserial seems to be a wrapper around lazsynaser, which I assume is from synapse.
>>
>> You should be OK just using directly lazsynaser.
>>
>> It has no GUI dependencies. The drawback is probably that you must create
>> the component in code instead of dropping it on a datamodule.
>
> I am anyway creating everything in code in a console application...
>
> The reason I went with LazSerial is that it was the closest in
> functionality I could find to the serial port component I used in the
> source Delphi program I am porting.
>
> For example I need the event model for retrieving the incoming data
> and the transmit must not be blocking.

Lazserial is simply a wrapper that allows you to set properties in the
designer. It adds no functionality, so you will not lose anything..

Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus