LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert hex-like string to hex or ascii

Solved!
Go to solution

I apologize for the unhelpful title, but I'm not sure how to explain this.

 

I have a list of "hex-like" values that are payloads captured from tcp packets between third party software and a lab device. The software sends commands to the device over TCP and those are the packets I have captured.

Wireshark exports the data into "hex like" strings such as "59454d0d50" or "5851562c320d01" and I have saved them into a list. When I read this list into LabVIEW using "Read from Text File", I get strings in that same format e.g. "59454d0d50". The problem is that this string is not what I want to use. It's not interpreted as "hex" it's interpreted as an ascii string. However, if I copy and paste this value into the str control with "display as hex" enabled, the str is "parsed" correctly and I get the true value I am looking for, which is some weird ascii value (see the images). Is there some way to get LabVIEW to parse this without needing to copy and paste into a string control?

Download All
0 Kudos
Message 1 of 11
(1,667 Views)
Solution
Accepted by topic author F34ewsd43

Hi F34,

 

welcome to the LabVIEW board!

 

See this as suggestion:

GerdW_0-1677699545859.png

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 11
(1,656 Views)

Hello,

 

look at this tutorial:

https://forums.ni.com/t5/LabVIEW/Complete-String-Conversion-Tutorial/m-p/4245188#M1234546

 

Perhaps recipe 05 or 06 is, what will help you.

 

P.S. I didn't quite understand, what kind of data you expect and how it is to be further processed. Do you expect numeric values? A text string? Please explain.

Greets, Dave
0 Kudos
Message 4 of 11
(1,586 Views)
Solution
Accepted by topic author F34ewsd43

Just another version as suggested by @GerdW

PalanivelThiruvenkadam_0-1677742824061.png

PalanivelThiruvenkadam_1-1677742881904.png

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 5 of 11
(1,568 Views)

Thank you for all the replies. I won't be able to test them for a few days, but I will give them a try and let you know once I do.

0 Kudos
Message 6 of 11
(1,545 Views)

The goal is to send a correctly formatted string using the TCP Write VI. I want to send the true ascii value of the "hex-like" strings I have, which means I need to convert them in some way. The ascii string "59454d0d50" is not the "hex" string "5945 4D0D 50" which has an ascii value of something like "YEM\rP". That value is what I want to send via TCP Write.

0 Kudos
Message 7 of 11
(1,529 Views)

This should do the trick. Had to make it once for myself.

Message 8 of 11
(1,511 Views)

Each of the three vi examples submitted gave me the output I was looking for. GerdW was first and thus wins the trophy. Thanks again for your help.

0 Kudos
Message 9 of 11
(1,393 Views)

Hi F34,

 

here's a loop-free suggestion:

GerdW_0-1678373077044.png

😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 11
(1,387 Views)