LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert a character string to a hexadecimal byte array

Solved!
Go to solution

Hello,

I want to take a character string and convert it to a hexadecimal byte array. So I can use the hex byte array for a EEPROM input. Does anyone have any ideas? Please let me know.

thanks

Joe

0 Kudos
Message 1 of 15
(2,465 Views)

Can you give an example of the string and what you expect it to look like after?

Tim
GHSP
0 Kudos
Message 2 of 15
(2,454 Views)

There's a built-in function for converting a string to a byte array, but can you clarify what you mean by a "hexadecimal byte array"? Do you just mean an array of U8s (a.k.a. bytes), in which case "hexadecimal" doesn't apply, or do you mean another string consisting of pairs of characters representing each byte in hexadecimal?

0 Kudos
Message 3 of 15
(2,452 Views)

It's always a Good Idea to attach some code where you try to solve your own problem.  This helps us by (a) telling us which version of LabVIEW you use (but only if you attach an actual VI, not a picture of one), (b) letting us see what you tried, (c) suggest ways for you to "fix it yourself" (and hence "Learn LabVIEW", if you don't know it already), and (d) if there is a real Error, helps us to "trap it in action".

 

It also provides a hint of how long you've used LabVIEW and how "gentle" we should be.

 

You didn't provide any code, so I'm going to guess you know almost nothing about LabVIEW.  You probably don't know how to open the Palettes on the Block Diagram and look for functions that might be suggestive (like one called "String to Byte Array").  You might not know how Strings are represented in LabVIEW.

 

Here's a suggestion.  Open LabVIEW.  Create an empty VI.  Open its Block Diagram.  Look at the String functions.  Look for "String to Byte Array".  Wire a String to its input, and wire an indicator to its output.  Run it.  Observe the Results.  Now use this to do something "useful".

 

Bob Schor

0 Kudos
Message 4 of 15
(2,445 Views)

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

0 Kudos
Message 5 of 15
(2,438 Views)

Again, please clarify what you mean by a "hex byte array". An array of bytes isn't inherently hexadecimal, that's just one format among many for representing the values in the bytes.

0 Kudos
Message 6 of 15
(2,426 Views)

I tried it this way but I dont think this is right

0 Kudos
Message 7 of 15
(2,425 Views)

sorry for the confusion... I included the SPI write VI and where I want to replace the data bytes written from a string command.. thanks again for your help

0 Kudos
Message 8 of 15
(2,411 Views)

Aha!  Now we have some indication of what you are trying to do, namely get LabVIEW to communicate via SPI to some other device.  If you had attached all of your code (the easiest way to have done that would be to compress the Folder that contained the entire LabVIEW Project and attach the resulting .ZIP file), we would have been better informed and those of us (which does not include myself) who have familiarity with I²C and SPI protocols could provide some real help.

 

I'd still suggest you attach the entire Project ...

 

Bob Schor

0 Kudos
Message 9 of 15
(2,401 Views)

@joeross wrote:

I tried it this way but I dont think this is right


That looks correct to me.  Something that might help you is to turn on the Radix on the numeric array (right-click, Visible Items->Radix).  You can then click on the little "d" that shows up and choose "Hex".  Now you will see the values in a Hexadecimal format instead of Decimal.  You can do something similar on the string controls/indicators except is it "Display Style" instead of Radix.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 15
(2,398 Views)