Reading string from Comm port
- From: "Ernest P. Woorell" <lkillen@xxxxxxxxxxx>
- Date: Sun, 20 May 2007 23:02:57 -0400
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;
.
- Follow-Ups:
- Re: Reading string from Comm port
- From: Ronaldo Souza
- Re: Reading string from Comm port
- From: Remy Lebeau \(TeamB\)
- Re: Reading string from Comm port
- Prev by Date: Re: adding bloging to my website
- Next by Date: Re: middleware for mysql
- Previous by thread: middleware for mysql
- Next by thread: Re: Reading string from Comm port
- Index(es):
Relevant Pages
|