07-23-2015 10:17 AM
Hello gents,
I am having this problem trying to send a string of 18 bytes in HEX according to my device request schema using the TCP Write.vi
As you can see in the attachments, if I use the concatenate string function and hard code the 18 bytes as constant as HEX display the message is valid and the device respond correctly.
The next step is to have byte F and byte 11 as user input so I have replaced the two constants "14" and "15" with two numerical inputs and using the Number To Hexadecimal String i connected the output of the function to Byte F and Byte 11.
The output of the Number To Hexadecimal String is correct as I input the value of 20 and the function converts to 14 (hex) if I have a indicator set to normal display.
If I change the indicator to Hex display then I get the ASCII representation of the value 20.
The problem is if I connect the output of the Number To Hexadecimal String to the Concatenate String instead of the constant the value 20 is represented as "3134" as ASCII.
How can I convert the value 20 that is an I32 to hex 14?
I have attached some screen shots of the code working with constants and not working with I32 to Hex conversation.
Solved! Go to Solution.
07-23-2015 10:44 AM - edited 07-23-2015 10:49 AM
Use 'number to hexadecimal string' in the string conversion palette. You can also use format into string.
If you are displaying (doesn't change the value) the number as a hexadecimal string then it is showing the hexadecimal character codes for the ASCII. You will get 2 'characters' per byte/ASCII character.
07-23-2015 10:51 AM
Since your values can only go into a single byte, change your data type of your two inputs to be U8 or I8. After than, just use Type Cast to change those bytes into a string.
07-24-2015 02:34 AM
Hi Sam,
Thank you very much for your time.
I have done exactly what you have suggested and the function converts the integer 20 into hex14 as you see on the attached picture.
But if I connect the output of the 'number to hexadecimal string' to the "concatenate strings" function it will insert the ASCII values, please picture on the output labelled "Request"
What I am doing wrong Sam?
Regards
Marian
07-24-2015 02:43 AM
Hi Crossrulz,
Thank you for your time, the typecast works OK.
Kudos to you.
Regards
Marian
07-24-2015 02:46 AM