Recent

Author Topic: Laz serial  (Read 2199 times)

michoux

  • New Member
  • *
  • Posts: 49
Laz serial
« on: June 23, 2021, 12:52:41 pm »
Hello,

I am trying to use TLazSerial for some serial data transmission.

I have 2 LazSerial components.
First reads the data from com port - virtual com port com0com ... parses some data
Second sends the received data to another serial port also virtual com0com

I see that sometimes all freezes application not responding any more.

Here is my code to receive and send:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.LazSerial1RxData(Sender: TObject);
  2. var xxx,rt,min,sec,st,alge,tis,dvo: string;
  3. begin
  4.   xxx:= LazSerial1.SynSer.RecvTerminated(1,char(10));
  5.   rt:=copy(xxx,4,8);
  6.   min:= copy(xxx,4,2);
  7.   sec:= copy(xxx,7,2);
  8.   st:= copy(xxx,10,2);
  9.   tis:=copy(xxx,11,1);
  10.   dvo:=copy(xxx,6,1);
  11.  
  12.   Memo1.Lines.BeginUpdate;
  13.  
  14.    Memo1.Lines.Add(min+sec+st);
  15.     Memo1.Lines.EndUpdate;
  16.   Memo1.SelStart := Length(Memo1.Lines.Text)-1;
  17.    Memo1.SelLength:=0;
  18.  
  19.  
  20.   if dvo=':'  then
  21.   alge:='A'+min+sec+st+'   : . '+char(13)
  22.   else
  23.   alge:='A'+min+sec+st+'     . '+char(13);
  24.  
  25.   if StrToIntdef(tis,0)> 0 then
  26.    alge:='A'+min+sec+st+tis+'  : . '+char(13);
  27.  
  28. Memo2.Lines.BeginUpdate;
  29.    Memo2.Lines.Add(alge);
  30.     Memo2.Lines.EndUpdate;
  31.   Memo2.SelStart := Length(Memo2.Lines.Text)-1;
  32.    Memo2.SelLength:=0;
  33.  
  34.   lazserial2.SynSer.SendString(alge);
  35.   lazserial2.SynSer.Flush;
  36.  
  37.  
  38. end;                                





michoux

  • New Member
  • *
  • Posts: 49
Re: Laz serial
« Reply #1 on: June 23, 2021, 01:05:02 pm »
Application hangs for some time, then again starts to receive data ... then again hangs ...

Here is my virtual port pair config.
COM120-COM121
COM4-COM5

3rd party app sends data to com120
lazserial1 Listens on COM121
lazserial2 sends data to COM4
Realterm listens on COM5


Perhaps it is because of virtual ports.
« Last Edit: June 23, 2021, 01:14:06 pm by michoux »

michoux

  • New Member
  • *
  • Posts: 49
Re: Laz serial
« Reply #2 on: June 23, 2021, 09:20:47 pm »
For outgoing port now I have "real" com port ...
It seems that sending the data to port with "lazserial2.SynSer.SendString(alge)" blocks my lazarus app ...
Strange is that it stay not responsive for some minute and then it continues ... and then again hangs :)

michoux

  • New Member
  • *
  • Posts: 49
Re: Laz serial
« Reply #3 on: June 24, 2021, 06:17:38 am »
So I made a small test with endless loop sending the data to serial

procedure TForm1.Button1Click(Sender: TObject);
begin
  lazserial1.Open;
  repeat
     lazserial1.WriteData('TEST 123');
  until false;
end;           


After few seconds data stops transmuting ... and then again continues, stops, continues ....

michoux

  • New Member
  • *
  • Posts: 49
Re: Laz serial
« Reply #4 on: June 24, 2021, 07:39:20 am »
I tested with "pure" synaser in this case no blockage no hang, serial works perfect.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   ser: TBlockSerial;
  4. begin
  5.   ser := TBlockSerial.Create;
  6.    ser.config(9600, 8, 'N', SB1, False, False);
  7.     ser.Connect('COM4');
  8.   repeat
  9.     ser.SendString('TEST 123 '+char(13));
  10.   until false ;
  11. end;                

 

TinyPortal © 2005-2018