LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data read from serial is raw data, How can i convert to HEX for parsing?

Solved!
Go to solution

 

 

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

 

 

0 Kudos
Message 1 of 6
(5,392 Views)

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.

 

 

Machine Vision, Robotics, Embedded Systems, Surveillance

www.movimed.com - Custom Imaging Solutions
0 Kudos
Message 2 of 6
(5,369 Views)

@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

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 3 of 6
(5,361 Views)

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

0 Kudos
Message 4 of 6
(5,317 Views)
Solution
Accepted by topic author Detox92

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.

Message 5 of 6
(5,308 Views)

Just what i was looking for thanks!

 

And thanks to everyone else who replied.

 

Alex

0 Kudos
Message 6 of 6
(5,300 Views)