LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert a character string to a hexadecimal byte array

Solved!
Go to solution

HI Bob,

that is basically it. All I want to do is replace that for loop that builds an array (data bytes written indicator) with a byte array converted from a string. Thank you for your help

Joe

0 Kudos
Message 11 of 15
(1,340 Views)

OK, Joe, we are ready to help you (or at least get you closer to what you want to do).  Here's what you do:

  • Make sure all the LabVIEW Files for your Project are in a single Windows Folder.  
  • Compress that folder into a .zip file (the original should remain intact).
  • Reply to this Message and attach the Zip file.  We need to see the Code to avoid wasting your time and ours.

Bob Schor

 

 

0 Kudos
Message 12 of 15
(1,320 Views)

 


@joeross wrote:

sure... say it is a module number for example AF1234... i want to convert this into a hex byte array to save to an EEPROM.. then read it back from the EEPROM and convert it back to the string.. thanks for your help


A byte array stores an array of 8 binary bits.  It doesn't care if you want to look at the number as hex, decimal, or as a character.

 

It would be easier if you told more about the expected conversion. But as i understand it you have a string of hexadecimal numbers where pairs of two numbers represent a byte. So the string "AF1234" shall be converted to an byte array with the values 0xAF, 0x12, and 0x34 (175, 18, 52 in decimal)

Is this what you need?
hexstring2byte_snippet.png

Use "Number to hexadecimal string" to convert from byte array to string array and then concatenate the string array when going the other way around.

0 Kudos
Message 13 of 15
(1,298 Views)

@joeross wrote:

sure... say it is a module number for example AF1234... i want to convert this into a hex byte array to save to an EEPROM.. then read it back from the EEPROM and convert it back to the string.. thanks for your help


Or if you want the string "AF1234" to be converted to byte array with values 0x41, 0x46, 0x32, 0x32, 0x33, 0x34 (65, 70, 49, 50, 51, 52 in decimal) then use the "String to byte array"-function.
String_to_byte_array.png

 

I have LabVIEW 2012 so have not looked at the code attached earlier.

0 Kudos
Message 14 of 15
(1,290 Views)
Solution
Accepted by topic author joeross

this worked! thank you everyone for their help

joe

0 Kudos
Message 15 of 15
(1,250 Views)