Recent

Author Topic: Sdpo serial component received data problem  (Read 12712 times)

wiz

  • New Member
  • *
  • Posts: 15
Sdpo serial component received data problem
« 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?

wiz

  • New Member
  • *
  • Posts: 15
Sdpo serial component received data problem
« Reply #1 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.

touchring

  • Full Member
  • ***
  • Posts: 174
Re: Sdpo serial component received data problem
« Reply #2 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;         

Mike James

  • New Member
  • *
  • Posts: 23
Re: Sdpo serial component received data problem
« Reply #3 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=-

touchring

  • Full Member
  • ***
  • Posts: 174
Re: Sdpo serial component received data problem
« Reply #4 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;     

touchring

  • Full Member
  • ***
  • Posts: 174
Re: Sdpo serial component received data problem
« Reply #5 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;