Author Topic: Detecting Data packets  (Read 1374 times)

sbeaulie

  • Newbie
  • *
  • Posts: 13
    • View Profile
Detecting Data packets
« on: May 15, 2012, 01:24:14 pm »
Is there any way to detect variable length data coming in with a $1B as the start of the packet but no specific end character?

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Detecting Data packets
« Reply #1 on: May 15, 2012, 01:44:50 pm »
Hello

Yes of course, it's possible.
For example our kermit implementation waits start char and calculates necessary packet length at run time on every detected packet.

You need add data packet definition with PacketBegin := #$1b; and add handler OnPacketLength that changes data packet length.
See kermit implementation below:

Code: [Select]
procedure TnrKermit.HandlePacketLength(Packet: TnrDataPacket; chData: byte;
  var IsHandled: Boolean);
begin
  // detect variable datapacket length and set it into needed property ...
  Packet.PacketLength := byte(chData) - 32 + Packet.DataLength;
  IsHandled := True;
end;

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sbeaulie

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Detecting Data packets
« Reply #2 on: May 15, 2012, 03:00:50 pm »
I looked a the Kermit demo and I don’t see the on packet handler  and unfortunately I’m not a professional  programmer and I don’t know how to add a handler for OnPacketLength. Could you give me an example

This is all I see in the Kermit demo


    procedure Button2Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure nrKermit1FileStart(Sender: TObject);
    procedure nrKermit1ChangeState(Sender: TObject);
    procedure nrKermit1FileEnd(Sender: TObject);
    procedure nrKermit1Error(Sender: TObject);
    procedure nrKermit1FatalError(Sender: TObject; ErrorCode,
      Detail: Cardinal; ErrorMsg: String; var RaiseException: Boolean);
    procedure nrKermit1Progress(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private declarations }                           
  public
    { Public declarations }       
  end;

var
  Form1: TForm1;

implementation

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Detecting Data packets
« Reply #3 on: May 16, 2012, 11:07:43 am »
Hello

There are small misunderstanding between us :-).

I mean Kermit sources, you look at Kermit Demo.

You can open DataProc demo, select  nrDataProcessor1 component and click DataPackets property in Object Inspector.
You will see DataPacket list. Select any datapacket and you will find OnPacketLength event in object inspector.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sbeaulie

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Detecting Data packets
« Reply #4 on: May 16, 2012, 12:35:16 pm »
Thank you !

sbeaulie

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Detecting Data packets
« Reply #5 on: May 16, 2012, 02:02:07 pm »
Hi It’s me again (the pain in the butt) I tried using the event handle

procedure TForm1.nrDataProcessor1DataPackets0PacketLength(Packet: TnrDataPacket;
  chData: Byte; var IsHandled: Boolean);
begin
// detect variable datapacket length and set it into needed property ...
  Packet.PacketLength := byte(chData) - 32 + Packet.DataLength;
  IsHandled := true
end;
 
with a PacketStart of #$1B expecting to see the the packets below

1B[=2l
1B.0
1B=)-
1Br1232
1B=)_YES
1Bq
1B=*-
1Br1237
1B=*_YES
1Bq
1B=+-
1Br1230
1B=+_Y
Etc…

But what I got was several long packets like the one below

1B[=2l1B.01B=)-1Br12321B=)_YES1Bq1B=*-1Br12371B=*_YES1Bq1B=+-1Br12301B=+_Y
ETC….

I’m very confused

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Detecting Data packets
« Reply #6 on: May 17, 2012, 04:36:38 am »
Hello

You initially asked:
Code: [Select]
Is there any way to detect variable length data coming in with a $1B as the start of the packet but no specific end character?
Do you understand how to detect length of variable part of packet after $1b char?
Do you have protocol description?

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sbeaulie

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Detecting Data packets
« Reply #7 on: May 21, 2012, 02:43:00 pm »
I am trying to figure out how to detect the variable length part of the packet so I can send the commands to the terminal (Memo) . I am trying to emulate a TelaVideo 995 dumb terminal.  The packets start 1B (ESC) and can have any number of hex codes following depending on what the commands are.

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Detecting Data packets
« Reply #8 on: May 22, 2012, 10:30:12 am »
Hello

If you do not understand how your protocol works, nrComm Lib will not help you :-)
Sorry.


Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sbeaulie

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Detecting Data packets
« Reply #9 on: May 22, 2012, 02:08:44 pm »
we have a misunderstanding I know the protocol and all of the ESC sequences and how to implement them I just can’t detect them because the length of the packet is variable and there is no end of packet.

Example

Packet Begin  =  $1B
Packet End  =  none
Packet Length = Variable

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Detecting Data packets
« Reply #10 on: May 23, 2012, 05:37:10 am »
Hello

Good  :-)

Please understand that If packet has variable length it should provide info about this length.
If you do not see length info in packet after 1b char, computer can not see it too. Miracles do not happen.
I explain obvious things.

It seems like your protocol is something like VT100/ANSI ESC-sequence protocol.
You need find and download its specification.
When you investigate it you will learn that all packets have fixed length. For example:

1Br1237
1Br1230

are Packet with
PacketBegin := $#1B'r';
PacketLength := 6;

1Bq
1Bq
are Packet with
PacketBegin := $#1B'q';

and so on ...

You need declare many packet definition for correct detection them.

For example look at here
http://www.braun-home.net/michael/info/misc/VT100_commands.htm

Better if you will find good skill programmer and he will resolve this task easy.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sbeaulie

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Detecting Data packets
« Reply #11 on: May 23, 2012, 12:39:03 pm »
Hi Roman,

You are correct  :)

The only command that was giving me trouble is $#1Br******* insert text  at cursor position. The text can be any length. I was hoping for an easy way of detecting the data but I guess life isn’t that simple !
I’ll write a parsing function and get the info that way.  Thank you for the help I appreciate your time and effort.
 
Steve B.