NetXMS Support Forum

English Support => General Support => Topic started by: yordi on December 18, 2019, 12:11:13 PM

Title: Hex-String to text DCI transformation
Post by: yordi on December 18, 2019, 12:11:13 PM
Hi,

With a DCI i get a Hex-string  "56 4E 42 51 44 39 4B 30 59 46"
Online i can let it translate to text ( https://coding.tools/hex-to-ascii (https://coding.tools/hex-to-ascii) ) , then i get "VNBQD9K0YF" This is a serial number of a printer.

Ho knows the Netxms scripting language to use in de transformation part of the DCI to get this Hex-string transformed to text in Netxms?

Greetings
Title: Re: Hex-String to text DCI transformation
Post by: Victor Kirhenshtein on December 18, 2019, 03:43:54 PM
Hi,

this script will transform first argument from hex string (space separated) into text:

l = length($1);
out = "";
for(i = 1; i < l; i += 3)
out .= chr(x2d(substr($1, i, 2)));
return out;


You should be able to use it as is in DCI transformation.

Best regards,
Victor
Title: Re: Hex-String to text DCI transformation
Post by: yordi on December 19, 2019, 11:28:38 AM
Thanks, Victor

Works perfect !!