Lazarus

Programming => Packages and Libraries => Ported from Delphi/Kylix => Topic started by: wiz on May 11, 2008, 08:49:42 pm

Title: Sdpo serial component received data problem
Post by: wiz on May 11, 2008, 08:49:42 pm
Has any body tried the Sdpo serial component with Lazarus.

The incoming data stream has a CR/LF inserted into it after every eight bytes received.

Can any body tell me where they are coming from?
Title: Sdpo serial component received data problem
Post by: wiz on May 15, 2008, 12:05:42 am
It is caused by a timing issue.

Adding a trial & error sleep() command to the start of the TSdpoSerial.OnRxData event allows time for the synaser text buffer to fill with complete lines of received text before using Memo.Lines.Add to display them.

The TMemo component was adding the CR/LF after each incomplete packet of data was Added.
Title: Re: Sdpo serial component received data problem
Post by: touchring on December 10, 2009, 11:45:46 pm
I was trying out the demo.  Could open port, but the memo only displayed whatever i sent.  For example, if I send AT, it displays AT.  The original synaser demo worked fine.  I tried adding sleep(3000) as follows, but it doesn't help.  What have i done wrongly?  :(

procedure TFMain.SerialRxData(Sender: TObject);
begin
  sleep(3000);
  Memo.Lines.Add(Serial.ReadData);
end;         
Title: Re: Sdpo serial component received data problem
Post by: Mike James on December 11, 2009, 10:28:10 am
The SDPO serial component works fine.

I found it best to buffer the incoming data into a TQueue. In the received data event copy all received data bytes into the TQueue. Then in a TTimer event parse the bytes in the TQueue.

Regards,

-=mike=-
Title: Re: Sdpo serial component received data problem
Post by: touchring on December 12, 2009, 08:01:14 am
I tried the following, doesn't work as well.   :(

procedure TFMain.SerialRxData(Sender: TObject);
var
i:integer;
s,s1:string;
begin
  s:='';
  for i:=1 to 20000 do begin
  s:= Serial.ReadData;
  if s<>'' then s1:=s1+s;
  end; //for
  Memo.Lines.Add(s1);
end;     
Title: Re: Sdpo serial component received data problem
Post by: touchring on December 12, 2009, 08:54:05 am
I found the problem.  Thanks for your comments.   :D

Had to amend:

procedure TFMain.BSendClick(Sender: TObject);
begin
  Serial.WriteData(EditSend.Text+#$0D);
end;                             
TinyPortal © 2005-2018