LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I convert a string of hex values to a hex format string programatically?

Solved!
Go to solution

Is there a way to convert a string of the following format:

 

1400010107070D0305006A01 ........           ("Normal display" string)

 

programatically to:

 

1400 0101 0707 0D03 05006A01 ..........      ("Hex display" striing)

 

I need to do this in order to calculate a CRC16 value.

 

See attached VIs

 

Thank you.

Download All
0 Kudos
Message 1 of 21
(5,138 Views)

Hi chuck,

 

1) search the forum, this has been asked a lot of times before

 

or

 

2) make a loop, get 2 chars from the string, convert to U8 number (by hex string to number),  convert the resulting U8 array to string (by U8 array to string function)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 21
(5,132 Views)

You can iterate over the string and use the String to Hex VI. If you work with two bytes of the string at a time you can get a U8 array of the desired binary values. Then when you are complete you can either work with the byte array of convert it back to a string using Byte Array to String.

 

EDIT: GerdW typed faster than I did.

Message Edited by Mark Yedinak on 03-18-2010 02:55 PM


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 3 of 21
(5,129 Views)

My problem is that the orignal string is in hex, but not hex format.

0 Kudos
Message 4 of 21
(5,125 Views)

Hi chuck,

 

your problem is you did not try what we told you to do Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 21
(5,119 Views)
Solution
Accepted by chuck72352

Here is exactly what we suggested.

 

 

Convert Hex String to Byte Array.png

Message Edited by Mark Yedinak on 03-18-2010 03:09 PM


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 6 of 21
(5,117 Views)
I was much kinder than you since I posted the solution. I was tempted to reply the same as you though. 😄


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 7 of 21
(5,115 Views)

Hi Mark,

 

I'm a grumpy old man Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 21
(5,112 Views)

Thank you, very impressive!

0 Kudos
Message 9 of 21
(5,102 Views)

Just for the heck of it.

 

HexString.png

Message 10 of 21
(5,094 Views)