Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Apr : Problem with SendBuffer for idTCPClient
| Subject: | Problem with SendBuffer for idTCPClient |
| Posted by: | "Glen Welch" (csd..@xtra.co.nz) |
| Date: | Wed, 20 Apr 2005 13:25:05 +1200 |
Indy Verion 9.00.10 Delphi Version 8
I am using a TidTCPClient to connect to a controller on a local lan, have
used indy TCP clients and servers on many occations but nothing like this.
I am able to establish a connection with it idClient but I think that my
problem is with the way I am sending the data.
I have another program (No code) that works fine and I am sending the same
data out - but getting a different response - I think that it is because I
am using an array an the data in the array isnt what is actually being sent
i.e. should I be using a pointer somehow?
This is the code I am Using:
procedure TForm1.SendCommand(Command: TFINSCommand; CommandLength: Integer);
var
A: TFINSCommand;
B: TFINSCommand;
I: Integer;
S, T: String;
const
HeaderLength = 26;
begin
A[00]:= $46;
A[01]:= $49;
A[02]:= $4E;
A[03]:= $53;
A[04]:= $00;
A[05]:= $00;
A[06]:= $00;
A[07]:= $14;
A[08]:= $00;
A[09]:= $00;
A[10]:= $00;
A[11]:= $02;
A[12]:= $00;
A[13]:= $00;
A[14]:= $00;
A[15]:= $00;
A[16]:= $80;
A[17]:= $00;
A[18]:= $02;
A[19]:= $00;
A[20]:= $08;
A[21]:= $00;
A[22]:= $00;
A[23]:= $EF;
A[24]:= $00;
A[25]:= fSID;
for I:= 0 to CommandLength do
A[I + HeaderLength]:= Command[I];
S:= '';
for I:= 0 to HeaderLength -1 + CommandLength do
begin
T:= Format('%x', [A[I]]);
while Length(T) < 2 do T:= '0' + T;
S:= S + T;
end;
Memo1.Lines.Insert(0, '<-- ' + S);
idOmron.WriteBuffer(Command, 1{aderLength + CommandLength});
inc(fSID);
idOmron.ReadBuffer(B, 16);
S:= '';
for I:= 0 to 15 do
S:= S + Format('%x', [B[I], 2]);
Memo1.Lines.Insert(0, '--> ' + S);
end;
Thanks in advance.