• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

String reception missing characters

Started by pipy71, July 20, 2010, 03:28:22 pm

Previous topic - Next topic

pipy71

I have a strange problem receiving incorrect hex strings using the 'codes_demo' application when i compile the demo app in delphi2010 (using pro trial version of nrComm)

however the pre-compiled codes_demo.exe trial application which can be downloaded from your website works correctly...

for example the correct received sting that is working is with..

$7E $00 $16 $92 $00 $13 $A2 $00 $40 $65 $23 $79 $FF $FE $02 $01 $00 $00 $07 $00 $00 $00 $00 $00 $00 $70

but the version i compile with delphi2010 from the demos folder I receive this string...

$7E $16 $00 $A2 $40 $23 $00 $00 $00 $00 $00 $79 $FE $01 $00 $00 $00 $00 $5A $00 $00 $00 $00 $00 $00 $00

notice how it appears to drop characters,

The first part of the string ($7E $00 $16 $92 $00 $13 $A2 $00 $40 $65 $23 $79 $FF $FE) should never change so they should match.

But for some reason there is a difference.

Does anybody know why?
I am running on windows XP

Thanks

Roman Novgorodov

July 20, 2010, 04:12:05 pm #1 Last Edit: August 09, 2010, 02:37:58 pm by Roman Novgorodov
Hello

Demo was created in Delphi 7, but D2010 uses unicode string by default.

Just replace PChar type on PAnsiChar and you will get correct result in D2010.
So now event handler will be following:

procedure TForm1.nrComm1AfterReceive(Com: TObject; Buffer: Pointer;
 Received: Cardinal);
var i:integer;
   s:string;
begin
 s:='';

 case grpRadix.ItemIndex of
   0:  for i:=0 to Received-1
         do s:=s+IntToStr(Byte(PAnsiChar(Buffer)[i]))+' ';
   1:  for i:=0 to Received-1
         do s:=s+'$'+IntToHex(Byte(PAnsiChar(Buffer)[i]),2)+' ';
 end;

 Memo1.Text:=Memo1.Text+s;
end;


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

pipy71


pipy71

Hello i need some more help please with regards to processing the received data,

I have tried with the data processor but i am not sure how to configure it for the start headers as it seams to output only ASCII characters and lots of characters are not visually readable so how do i convert this to individual hex packets that can be read?

example of the data transmitted... fixed length (56 individual characters after converted to hex) packets always start with 7E00.

here is several packets of data which is received after doing  s:=s+IntToHex(Byte(PAnsiChar(Buffer)[i]),2); after receive event...

7E0018920013A20040652312FFFE020100000F02840223022203FFFE7E0018920013A200406A33DDFFFE020100000F012001E6025A02D0B97E0018920013A20040652312FFFE020100000F0264020401FF03FF617E0018920013A20040652312FFFE020100000F02640204020003FF5F7E0018920013A20040652312FFFE020100000F0263020401FF03FF627E0018920013A200406A33DDFFFE020100000F014A023A038003FCE67E0018920013A20040652312FFFE020100000F02640205020003FF5E7E0018920013A200406A33DDFFFE020100000F00F101AC01F8026CEA7E0018920013A20040652312FFFE020100000F02660206020203FF597E0018920013A200406A33DDFFFE020100000F015E0260038003FEAA

Please advise

Thanks


Roman Novgorodov

Hello

You can create packet or change packet properties at runtime.
Something like following:

procedure TForm1.FormCreate(Sender: TObject);
var packet:TnrDataPacket;
begin
  packet := nrDataProcessor1.DataPackets.Add;
  packet.PacketBegin := #$7E#$00;
  packet.PacketLength := 56;
  packet.Active := True;
end;


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