Recent

Author Topic: RawData and Indy  (Read 287 times)

BlueIcaro

  • Hero Member
  • *****
  • Posts: 576
RawData and Indy
« on: May 24, 2019, 03:43:33 pm »
Hi I make a small server with TIdTCPServer. I quite simple. I send from other machine some string and the server shows it on a memo.
That's works fine.
I connect this server to read info from a machine that sends info in rawdata. But I can`'t read anything


Also I tested small server example from wiki : http://wiki.freepascal.org/Light_Web_Server
And I don't receive any thing. I thing I using a wrong instruccion or method.

How can read/receive some RawData?

Thanks in advance
/BlueIcaro
P.D  May be using other library?
« Last Edit: May 24, 2019, 04:52:33 pm by BlueIcaro »
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 616
    • Lebeau Software
Re: RawData and Indy
« Reply #1 on: May 24, 2019, 07:13:52 pm »
I connect this server to read info from a machine that sends info in rawdata. But I can`'t read anything

Can you be more specific?  What does your code look like?  What does the raw data look like?

Also I tested small server example from wiki : http://wiki.freepascal.org/Light_Web_Server
And I don't receive any thing. I thing I using a wrong instruccion or method.

That implies that your "other machine" is either not connecting to the server at all, or is not sending any data to the server once connected.  Really hard to diagnose without more details about what you are really dong on each side, what the network traffic looks like, etc.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

BlueIcaro

  • Hero Member
  • *****
  • Posts: 576
Re: RawData and Indy
« Reply #2 on: May 27, 2019, 09:29:33 am »
Hi, thanks for answer Remy, The other machine connects to my program, because  the Execute events are fired.
Code: [Select]
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var
  LLine: string;
  W: UInt16;
  c: Byte;
begin
  TIdNotify.NotifyMethod(@ShowStartServerMessage);
  AContext.Connection.IOHandler.ReadTimeout:=5000;
  Memo1.Clear;
  w:=0;
  W := AContext.Connection.IOHandler.ReadWord(TRue);
  c := AContext.Connection.IOHandler.ReadByte;
  Memo1.Lines.Add(IntToStr(c));
  Memo1.Lines.Add(IntToStr(w));
  // AContext.Connection.IOHandler.WriteLn();
  TIdNotify.NotifyMethod(@ShowStopServerMessage);
end;
The industrial machine (ABB robots) says this about the instruction.
Quote
PackRawBytes is used to pack the contents of variables of type num, dnum, byte,
or string into a container of type rawbytes.
Quote

Thanks
/BlueIcaro
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 616
    • Lebeau Software
Re: RawData and Indy
« Reply #3 on: May 29, 2019, 06:04:18 am »
Hi, thanks for answer Remy, The other machine connects to my program, because  the Execute events are fired.
Code: [Select]

Your code contains unsafe operations.  ALL access to the UI must be synchronized.  That includes your TMemo logging.  Bad things happen when you don't synchronize correctly, including deadlocks, crashes, and dead UIs.  You need to fix that.

[quote author=BlueIcaro link=topic=45511.msg322176#msg322176 date=1558942173]
The industrial machine (ABB robots) says this about the instruction.
[quote]
PackRawBytes is used to pack the contents of variables of type num, dnum, byte,
or string into a container of type rawbytes.
[quote]
[/quote]

That doesn't tell me anything useful about what the ACTUAL DATA looks like on the network.  Your code assumes a 2-byte Word in network byte order, followed by a Byte.  Is that what is actually documented?  What about the rest of the data?  I found some ABB Robotics documentation, but it only describes the function calls, not what the underlying data looks like.  I see a PackDNHeader function call usually precedes a PackRawBytes function call.  What does the header data look like?  What does the body data look like?  Can you please provide an example message being sent by the robot and what the RAW BYTES on the socket actually look like?  Otherwise, I can't help you come up with the correct Indy code to handle the data properly.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)