Author Topic: Sending Hex Data  (Read 3527 times)

ata90

  • Newbie
  • *
  • Posts: 2
    • View Profile
Sending Hex Data
« on: February 17, 2011, 10:55:46 pm »

     Dear Roman

How can I send hex data to serial port? for example sending '0A 12 FE 20'

Thank you
Ata

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Sending Hex Data
« Reply #1 on: February 18, 2011, 03:45:21 am »
Hello

You can try something like this:

nrComm1.SendString(#$0A#$12#$FE#$20);

If you have a byte arraywith needed data you can use its pointer in SendData method.

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.

ata90

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Sending Hex Data
« Reply #2 on: February 18, 2011, 06:34:03 am »

     Dear Roman

Many Thanks for your reply.
About the SendData(Buf:PChar;N:integer) procedure which u mentioned in your comment, what's N parameter and can you please make an example of this procedure about sending byte array of hex data to serial port?


Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Sending Hex Data
« Reply #3 on: February 18, 2011, 06:45:59 am »
Hello

Something like this:

Code: [Select]
Const
  sizeData = 4;
var
  myData:array[0.. sizeData-1] of byte = ($0A,$12,$FE,$20);
begin
    nrComm1.SendData(@myData[0], sizeData);
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.