Recent

Author Topic: TLazSerial : serial port component for Lazarus (windows and linux).  (Read 342191 times)

mas steindorff

  • Hero Member
  • *****
  • Posts: 526
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #300 on: March 05, 2020, 03:11:13 am »
FYI: I use synaser as a unit in it's own thread running at 921,600 baud.  The end device streams binary data to my program using DMA so the spacing between bytes is as small as possible (2 or 3 bit times).  synaser works well for me here.  The (my) program is is responsive where other comm programs will lock up until there is a pause in the data stream.  Tested both Realterm and TaraTerm with the same results.  The big difference is they try to show each byte where I only display a summery.
IMHO you will find the display update is your bottle neck unless your using something like OpenGL.
windows 7/10 - laz 2.0 / 1.2.6 general releases

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #301 on: May 01, 2020, 10:45:23 am »
hello,
a new version (0.3)  of the component is available here

 new in v0.3 version
 Add conditional macros for cpuarm rpi in lazsynaser.pas
 Hide Active property from IDE Object inspector

checked on Windows 10 Lazarus 2.0.8    and   Linux Centos 8  Lazarus 1.8.2 

wp,  you can put this update in your online package manager.

Friendly, J.P         
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #302 on: May 01, 2020, 10:46:51 am »
wp,  you can put this update in your online package manager.
Please contact GetMem. I don't have access to the OPM repo.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #303 on: May 01, 2020, 10:50:11 am »
oops sorry  :-\    the message
Quote
you can put this update in your online package manager.
is for GetMem

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

balazsszekely

  • Guest
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #304 on: May 01, 2020, 11:48:28 am »
Quote
you can put this update in your online package manager.
Done. Thank you!

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #305 on: May 08, 2020, 09:59:59 am »
Probably stupid question, but:
Can LazSerial be used with Delphi 2007 in some way?

I am trying to prepare a D2007 service project for porting to FPC/Lazarus by identifying stuff that relies on external components and the like and converting these to somewhat native Delphi or else FPC type units.
I have already moved a lot of stuff I could understand myself to no longer rely on the external units, but the serial comm is not there yet. I use the Turbo Async Pro serial component for the original code and I want to exclude this before using the Lazarus Delphi converter since otherwise it will bring in so many of the Async Pro units...

And today I just flashed a thought:
Maybe LazSerial can be used already in Delphi 2007? That would simplify the porting a lot since LazSerial is what I intend to use in the final solution.
But I must make sure the prepared project in D2007 still builds and works the same as before...

Note:
In the project all components are created in code, there is no "drop on form" automatic handling of them, so I know exactly where they are actually handled.
--
Bo Berglund
Sweden

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #306 on: May 10, 2020, 12:35:16 am »
hello,
Probably stupid question, but:
Can LazSerial be used with Delphi 2007 in some way?
No.

Quote
In the project all components are created in code, there is no "drop on form" automatic handling of them, so I know exactly where they are actually handled.

Use Synaser library.

Friendly, J.P

Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Mark20

  • New Member
  • *
  • Posts: 36
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #307 on: June 02, 2020, 12:47:44 pm »
Hello,
just installed the useful TLazSerial and was wondering how enumerate the serial ports available in the system (Win or RPi)...
Also looking for a blocking function which read all until received a specific char or Timeout...
In the past posts I see references to a synaser object but do not understand how use it....
Can you Help ?
Regards

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #308 on: June 02, 2020, 05:46:14 pm »
hello,
have a look to the RecvTerminated function
Quote
function RecvTerminated(Timeout: Integer; const Terminator: AnsiString): AnsiString; virtual;
This method waits until a terminated data string is received. This string is terminated by the Terminator string. The resulting string is returned without this termination string! If no data is received within the Timeout (in milliseconds) period, LastError is set to ErrTimeout.

to access to this function from for example myLazSerial  TLazserial component :
myLazSerial.SynSer.RecvTerminated

Friendly, JP
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Mark20

  • New Member
  • *
  • Posts: 36
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #309 on: June 02, 2020, 11:53:50 pm »
Thank you very much JP !

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #310 on: July 22, 2020, 10:38:15 am »
I ran into a difficult problem with LazSerial when I integrated it as a replacement for a Delphi-only serial port component into a Delphi -> Lazarus conversion.
Originally when I tested LazSerial for this purpose I was using a GUI project and then I received help here to make it build on both Windows10 and Linux (Raspbian).

But now when I am using it in a console program which will run as a systemd service on Linux I cannot get the project to build!

I can do quick compile and it succeeds but as soon as I do a build to get the executable it fails in the linking step with a large number of error messages like these:
Code: Text  [Select][+][-]
  1. wsmenus.pp(263,1) Error: undefined reference to `WSRegisterMenu'
  2. wsmenus.pp(263,1) Error: undefined reference to `WSRegisterPopupMenu'
It seems like it is bringing in GUI dependencies into the project and since it is a console program this is a no-no...
I googled and found basically the same issue in a thread here named "Using LazSerial in console application" from 2013!

Unfortunately a solution is described that I feel is not really working, so I need some advice here on what to do.
I have looked over all of my own source files and removed all GUI-related stuff including units in uses clauses that reference GUI related items.
The application compiles successfully using "Quick Compile" but when building it fails in the final linking step and spews out all these errors like in the linked post.

Question:
How can I use LazSerial in a non-gui console application on Linux?
--
Bo Berglund
Sweden

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #311 on: July 23, 2020, 01:21:12 am »
hello,
TLazSerial is a component for GUI application. For console application use synaser.
Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #312 on: July 23, 2020, 07:38:02 am »
UPDATE:
In the unit where LazSerial is referenced I added an extra uses item
like this:

Code: Pascal  [Select][+][-]
  1.   {$IFDEF FPC}
  2.     interfaces, //Needed for LazSerial to work in a Console program
  3.     LazSerial,  //The serial component
  4.   {$ELSE} //Delphi

When I now build the project the linker does not trigger any
complaints about missing Menu related identifiers and the build
succeeds!

Why this happens I don't know and also if it is still going to work, so far I have yet to check the functionality of LazSerial. For that I need some hardware devices attached to the RPi4B unit, which I don't have available where I am now.
But now I can continue working on other parts of the application without being stopped by the linking error from LazSerial.  :)
--
Bo Berglund
Sweden

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #313 on: July 23, 2020, 09:33:54 am »
Code: Pascal  [Select][+][-]
  1.   {$IFDEF FPC}
  2.     interfaces, //Needed for LazSerial to work in a Console program
  3.     LazSerial,  //The serial component
  4.   {$ELSE} //Delphi

When I now build the project the linker does not trigger any
complaints about missing Menu related identifiers and the build
succeeds!

The Interfaces unit links in the GUI widgetset of the LCL which is not really what you want for a command line application. Do as Jurassic Pork (and Michael on the mailing list) suggested and use the serial component of Synaser directly (TLazSerial is "simply" a GUI wrapper for that).

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #314 on: July 28, 2020, 06:25:57 pm »
Code: Pascal  [Select][+][-]
  1.   {$IFDEF FPC}
  2.     interfaces, //Needed for LazSerial to work in a Console program
  3.     LazSerial,  //The serial component
  4.   {$ELSE} //Delphi

When I now build the project the linker does not trigger any
complaints about missing Menu related identifiers and the build
succeeds!

The Interfaces unit links in the GUI widgetset of the LCL which is not really what you want for a command line application. Do as Jurassic Pork (and Michael on the mailing list) suggested and use the serial component of Synaser directly (TLazSerial is "simply" a GUI wrapper for that).

Back again...
The trick with adding interfaces to the uses clause just before LazSerial "seemed" to work.

But that was because I was running my console app inside a terminal window in Raspbian Buster on an RPi4.
Today I tried to run it inside a PuTTY SSH shell window connected to that same RPi4.
The result was that I got this error:
Code: Text  [Select][+][-]
  1.     $ ./SSRemoteServerLx
  2.  (SSRemoteServerLx:5753): Gtk-WARNING **: 14:39:10.439: cannot open display:

Apparently there are GUI dependencies that are not met in a "real" console and stops the application from even starting up.
Since the program must in the end run as a Systemd service on an RPi4 server with noone logged on it must not behave this way...

So now I am coming back to this problem once more, how can I remove the GUI dependencies from LazSerial?
Or how can I use SynaSer directly, as has been suggested, when it is blocking and the code (rather big) I am porting is using an event driven concept for receiving data?

As far as I can see the Synaser serial component uses blocking reads rather than events to signal arrival of data to read...
Do you know of any Synaser adaptation adding an OnRxData() event such that it can fire as the event on LazSerial does but does not bind in GUI dependencies?
--
Bo Berglund
Sweden

 

TinyPortal © 2005-2018