Reading string from Comm port



I am having trouble reading from a Com port. I have no controll over the
Sending app. It is to sent to me GETDATA and I am to replay with either
data or ALIVE. That is the protocol.

I am using Com Port Library 3.1

I listen using the ComPort1RxChar(Sender: TObject; Count: Integer);

My problem is that the G always comes first and then some portion of the
remainder of the string.

What I want is a result along the lines of

If Str = 'GETDATA' then
ComPort1.WriteStr(Chr(02)+'ALIVE2'+Chr(03));

I amd successfully able to read GETDATA into the Memo1 box by putting the
charaters together but I cannot get the If to fire.

I am not sure of the delimiters being used by the sender. In
Hyper-Terminal, I see none. But I should be able to filter out everything
but 'GETDATA' , right? Can someone throw me a bone on how to do this?


procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);
var
Str: String;
fBuffer : String;
begin
ComPort1.ReadStr(Str, Count);
Memo1.Text := Memo1.Text + Str;
fBuffer := fBuffer + Str;
If fBuffer = 'GETDATA' then
Begin
ComPort1.WriteStr(Chr(02)+'ALIVE2'+Chr(03));
End;
end;


.



Relevant Pages

  • Re: Reading string from Comm port
    ... btw - GETDATA is the command being sent to my app. ... // Process each character coming in, ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: HTML not generated on client
    ... ImageUrl2 = szUrl; ... protected string GetData2() ... return ImageUrl2; ... GetData() sets a property with it's return string, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HTML not generated on client
    ... In Page_Load, the code sets ... GetData() sets a property with it's return string, ... the html for ImageSec, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: write read string data
    ... GetData getData1 = new GetData; ... public class GetData extends JPanel { ... and then you compare it to a String. ...
    (comp.lang.java.help)
  • Re: Reading string from Comm port
    ... btw - GETDATA is the command being sent to my app. ... STX/ETX demiters since the author of that piece requires it. ... fBuffer: String; ... But take into account what happens if you get a stream like ...
    (borland.public.delphi.thirdpartytools.general)