Forum > Packages and Libraries

Laz serial

(1/1)

michoux:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.LazSerial1RxData(Sender: TObject);var xxx,rt,min,sec,st,alge,tis,dvo: string;begin  xxx:= LazSerial1.SynSer.RecvTerminated(1,char(10));  rt:=copy(xxx,4,8);  min:= copy(xxx,4,2);  sec:= copy(xxx,7,2);  st:= copy(xxx,10,2);  tis:=copy(xxx,11,1);  dvo:=copy(xxx,6,1);   Memo1.Lines.BeginUpdate;     Memo1.Lines.Add(min+sec+st);    Memo1.Lines.EndUpdate;  Memo1.SelStart := Length(Memo1.Lines.Text)-1;   Memo1.SelLength:=0;    if dvo=':'  then  alge:='A'+min+sec+st+'   : . '+char(13)  else  alge:='A'+min+sec+st+'     . '+char(13);   if StrToIntdef(tis,0)> 0 then   alge:='A'+min+sec+st+tis+'  : . '+char(13); Memo2.Lines.BeginUpdate;   Memo2.Lines.Add(alge);    Memo2.Lines.EndUpdate;  Memo2.SelStart := Length(Memo2.Lines.Text)-1;   Memo2.SelLength:=0;   lazserial2.SynSer.SendString(alge);  lazserial2.SynSer.Flush;   end;                                



michoux:
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.

michoux:
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:
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:
I tested with "pure" synaser in this case no blockage no hang, serial works perfect.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);var  ser: TBlockSerial;begin  ser := TBlockSerial.Create;   ser.config(9600, 8, 'N', SB1, False, False);    ser.Connect('COM4');  repeat    ser.SendString('TEST 123 '+char(13));   until false ;end;                

Navigation

[0] Message Index

Go to full version