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

codes_demo works incorrect in Delphi2010

Started by crestxa, November 15, 2010, 02:21:07 pm

Previous topic - Next topic

crestxa

which I send HEX “ED 7E 98 0C 6E 19 32 30” by RS232
but  what I get is $ED $98 $6E $32 $00 $00 $00 $00
WHY

Roman Novgorodov

Hello

Please show me your code that sends and receive data.
Possible you use unicode string type that is default for new delphi versions.

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.

crestxa

I know something wrong about unicode string ,but how  can I fix it,thanks
(In delphi7 it's work well)

receive data I use X:\Program Files\nrComm Lib\Demos\Codes\codes_demo.dproj
Delphi2010

crestxa

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(PChar(Buffer)))+' ';
    1:  for i:=0 to Received-1
          do s:=s+'$'+IntToHex(Byte(PChar(Buffer)),2)+' ';
  end;

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

Roman Novgorodov

Hello

Thank you for your information.
The Codes Demo receives data only. It does not send anything.
We tested Codes demo again under Delphi XE and it works fine.

Please show me code that sends data.

Also please check that both applications have same serial port settings (baud rate parity and etc.).

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.

crestxa

I fixed it by change
s:=s+'$'+IntToHex(Byte(PChar(Buffer)),2)+' ';
to
s:=s+'$'+IntToHex(Byte(PAnsiChar(Buffer)),2)+' ';
It's work fine!

thanks,but Send data from hardware,
How to use nrcomm send,thanks
I use nrComm1.SendString(edit1.Text); But it's not work,It's my first time to use nrcomm,I look for help file,and demo ,but can not find answer,
procedure TForm1.Button2Click(Sender: TObject);
begin
  nrComm1.SendString(edit1.Text);
end;

Roman Novgorodov

Hello

Thank you for your information. Yes, your solution is correct.

Also you can try to send string as following:

procedure TForm1.Button2Click(Sender: TObject);
begin
  nrComm1.SendString(AnsiString(edit1.Text));
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.