From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Hexadecimal String to Byte Array

Solved!
Go to solution
Solution
Accepted by Nelval

Hi Neival,

 

something like this may work for you:

check.png

(String in normal display mode…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 11 of 29
(5,422 Views)

I already came up with a solution pretty similar, I was expecting something a bit more builtin from LabVIEW, anyway, thanks.

 

 

Message 12 of 29
(5,410 Views)
Sorry for the misunderstanding... another way of doing the conversion
0 Kudos
Message 13 of 29
(5,403 Views)

And where do these "solutions" do a left padding of the last "4" in the original example string?

0 Kudos
Message 14 of 29
(5,399 Views)

Hi Christian,

 

why insist on left padding? Conversion of trailing "4" will give the expected result 4…

 

The question should rather be: Why does the data source omit the zero padding leaving us with an odd number of chars?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 15 of 29
(5,396 Views)

@GerdW wrote:

why insist on left padding? Conversion of trailing "4" will give the expected result 4…


Yes, yours does, but the other two don't.

0 Kudos
Message 16 of 29
(5,391 Views)
Solution
Accepted by Nelval

Here's what should cover all scenarios (odd or even lenght)

 

 

Message 17 of 29
(5,385 Views)

@altenbach wrote:

Here's what should cover all scenarios (odd or even lenght)

 

 


 

 

Thanks for completing that part of the solution.

0 Kudos
Message 18 of 29
(5,372 Views)

I know this post has been marked answered, but I just can't help myself.  And I do have the greatest respect for Chris' experience.

 

Mostly in answer to Vijay's several attempts (some flat-out wrong, and the final one close but improvable), I'll attach the following two images (note, only one is a snippet):

 

Efficient conversion of string of char pairs to U8 array.pngtire_swing.jpg

 

 

 

 

 

 

Apologies to all and best regards,

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 19 of 29
(5,331 Views)

for the fun of it:

 

HexStringToBytes.png

0 Kudos
Message 20 of 29
(5,315 Views)