Follow

Converting commands to ASCII Hex

When sending commands to a TCP connection we will often need to mix ASCII and Hex values.

Most control systems handle this problem through escape sequences. These will often look something like the following:

Note: Carriage Return and New Line are very common non-printable characters so special escape sequences exist for these values in most systems.

However, occasionally we will find a control system that does not support escape sequences, or the escape sequences are not well documented. In many of these cases the control system will still support a "Hex mode" which allows us to send data in ASCII Hex format.

In these cases we can convert the ASCII (human readable portion) of the command to ASCII Hex and then add our Hex values in the ASCII Hex directly.

  1. Determine the command that needs to be converted. For this example we will use one of our relay commands: setstate,1:1,1\x0d

    Note: All commands sent to port 4998 of GC units should be terminated with a carriage return (hex value 0D).
  2. Convert the ASCII portion of the command (in this case setstate,1:1,1) to Hex using an ASCII to Hex converter.

    Here is a good online converter:
    https://www.rapidtables.com/convert/number/ascii-to-hex.html

    The result for our example command is:
    73 65 74 73 74 61 74 65 2C 31 3A 31 2C 31
  3. Now add the hex portion of the command (in this case 0D) to the end of the Hex conversion:
    73 65 74 73 74 61 74 65 2C 31 3A 31 2C 31 0D
  4. Paste the converted command into our control system and select the Hex format.

Note on IR commands: IR commands can be very long and converting to ASCII Hex can make them even longer. One way to mitigate this is to first convert the commands from Global Cache to Global Cache (compressed) format using iConvert.

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk