01-15-2014 02:13 PM
Hi,
I read from a serial com port, and the data is Ascii form of HEX i think. The data i recieve is very similar to this:
Zî ”¢>î ™¢Tî ™¢Kî ¢Mî ¢iî ’¢Gî ’¢"î ‚¢0î ‚¢hî €¢ (Im not sure this has copied pasted correctly)
Yet when i change my output display to Hex display i see this:
5AEE 0302 0620 94A2 3EEE 0302 0620 99A2 54EE 0302 0620 99A2 4BEE 0302 0620 8FA2 4DEE 0302 0620 8DA2 69EE 0302 0620 92A2 47EE 0302 0620 92A2 22EE 0302 0620 82A2 30EE 0302 0620 82A2 68EE 0302 0620 80A2
How can I convert the string to hex output as above for parsing?
Many thanks
Alex
Solved! Go to Solution.
01-15-2014 02:55 PM
If I understand you correctly, you are wanting to take binary data, and convert is to HEX String Characters (In other words Alpha-Numberic 0-9, A-F).
If your original value is already s string character, you need to CAST it as a U8. Once you have the value as a U8, you can use the Numeric to Hex Sting VI.
01-15-2014 03:01 PM
@Detox92 wrote:
Hi,
I read from a serial com port, and the data is Ascii form of HEX i think. The data i recieve is very similar to this:
Zî ”¢>î ™¢Tî ™¢Kî ¢Mî ¢iî ’¢Gî ’¢"î ‚¢0î ‚¢hî €¢ (Im not sure this has copied pasted correctly)
Yet when i change my output display to Hex display i see this:
5AEE 0302 0620 94A2 3EEE 0302 0620 99A2 54EE 0302 0620 99A2 4BEE 0302 0620 8FA2 4DEE 0302 0620 8DA2 69EE 0302 0620 92A2 47EE 0302 0620 92A2 22EE 0302 0620 82A2 30EE 0302 0620 82A2 68EE 0302 0620 80A2
How can I convert the string to hex output as above for parsing?
Many thanks
Alex
There's no active "conversion" going on there. All you are doing at the top is looking at the ASCII symbols which are represented by the string, one character (2 bytes) at a time. If you want to make sure exactly where you're parsing things, just set up your strings in the BD to show the hex display (or "\ code"), not the ASCII characters (there are so many nonprinting ASCII characters that you have to do it this way anyway, unless you know that your data is readable text).
Cameron
01-15-2014 11:37 PM
Hi Cameron,
Many thanks for your quick response. I understand that the display is simply switching between the ASCII representation of the data and the HEX representation of the data also. The problem i am having is, when i seach my string for STX or 02 to find the start point of my data it returns nothing, yet when i switch the display output to show my data in Hex i can clearly see my STX and ETX values regularly.
Any help is much appreciated
Thanks again in advance
Alex
01-16-2014 12:44 AM
How are you doing this search? Show your code. You need to search by value, not by ASCII text. If you want a string search for a value of 02, not the text "02", then right-click the string constant, show \ code display, and enter \02.
01-16-2014 01:15 AM
Just what i was looking for thanks!
And thanks to everyone else who replied.
Alex