Sending ASCII and Hex

Feature Requests, Comments, Bugs, and Suggestions on the Intelliremote application.

Sending ASCII and Hex

Postby stbluesrul » Sat Jul 09, 2016 12:09 pm

I'm trying to send ASCII and Hex date like this:
Code: Select all
GlobalCache("192.168.1.101", 60128, "Hello $FA $82")

However, this does not work.
stbluesrul
 
Posts: 116
Joined: Thu Dec 17, 2009 8:53 pm
Location: Las Vegas, NV

Re: Sending ASCII and Hex

Postby Melloware » Sat Jul 09, 2016 12:46 pm

Hmmm what happens? I think I just send the GlobalCache the exact string you pass it?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11044
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Sending ASCII and Hex

Postby stbluesrul » Sat Jul 09, 2016 1:28 pm

Like you said, it's sending the exact data "Hello $FA $82".

In the manual it shows that you can send hex bytes by putting a $ character in front of each hex byte:
Code: Select all
GlobalCache("192.168.1.101", 4998, "$FA $82")

The above command does work as expected and it sends the hex bytes instead of ASCII. However, it seems that you currently cannot send hex bytes in the same line as ASCII. Would it be possible to add an escape character like \ to then be able to send hex bytes in the same line as ASCII?
Code: Select all
GlobalCache("192.168.1.101", 60128, "Hello \$FA \$82")
stbluesrul
 
Posts: 116
Joined: Thu Dec 17, 2009 8:53 pm
Location: Las Vegas, NV

Re: Sending ASCII and Hex

Postby Melloware » Sun Jul 10, 2016 12:00 pm

Oh I see what you are saying. Let me investigate that.

I created this ticket for myself:

https://app.assembla.com/spaces/mellowa ... nd/details
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11044
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Sending ASCII and Hex

Postby Melloware » Sun Jul 10, 2016 12:07 pm

OK here is the function I wrote:

Code: Select all
{-----------------------------------------------------------------------------
  Procedure: ConvertHexStringToCharacters
  Author:    Melloware <info@melloware.com>
  Date:      31-Dec-2009
  Desc:      Converts a hex string to characters for COM Port.
             Example: $FA $82 = 250 130 = ú ‚
-----------------------------------------------------------------------------}
function ConvertHexStringToCharacters(const HexString: string): string;
var
   Tokens: TStrings;
   strClean: string;
   i, iChar: integer;
begin
   Result := '';
   strClean := Trim(HexString);
   if not AnsiStartsStr('$', strClean) then
   begin
      Result := strClean;
      Exit;
   end;

   Tokens := TStringList.Create();
   try
      StrTokenToStrings(strClean, Char(' '), Tokens);
      for i := 0 to Tokens.Count - 1 do
      begin
         if AnsiStartsStr('$', Tokens.Strings[i]) then
         begin
            iChar := StrToInt(Tokens.Strings[i]);
            Result := Result + Chr(iChar);
         end
         else begin
            Result := Result + Tokens.Strings[i];
         end;
      end;
   finally
      Tokens.Free;
   end;
end;


I think I just need to remove the first check where if the string doesn't start with "$" I escape out. I think I should just remove the first check and the code should work the way you want it to...

Code: Select all
   if not AnsiStartsStr('$', strClean) then
   begin
      Result := strClean;
      Exit;
   end;
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11044
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Sending ASCII and Hex

Postby stbluesrul » Sun Jul 10, 2016 4:56 pm

Ok, great. Thanks for the quick response. Are you able to PM me a link for beta when it's ready to test?
stbluesrul
 
Posts: 116
Joined: Thu Dec 17, 2009 8:53 pm
Location: Las Vegas, NV

Re: Sending ASCII and Hex

Postby Melloware » Wed Aug 17, 2016 7:45 am

stbluesrul wrote:Ok, great. Thanks for the quick response. Are you able to PM me a link for beta when it's ready to test?


Yes I will send you a BETA!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11044
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA


Return to Intelliremote

Who is online

Users browsing this forum: No registered users and 3 guests