03-25-2010 10:00 AM
Solved! Go to Solution.
03-25-2010 10:07 AM
Hi chuck,
-convert the string to array of U8
-feed that array to an autoindexing FOR loop, convert each byte to hex string of length=2, add a space, wire the concatenated string out of the loop (resulting in a string array)
- wire the string array to a "concat string" node to get a single string, remove the last char (as it is a space)
03-25-2010 10:09 AM
03-25-2010 10:26 AM
No luck with that, but I was able to do it in C and put the result in a file then access it from Labview.
Thank you.
03-25-2010 10:47 AM
03-25-2010 10:52 AM - edited 03-25-2010 10:54 AM
The following snipit will do the job no matter how long the input string is, as long as it is an even number of characters. Another requirement is that the input string should not have any spaces. If it does, just create code to remove spaces from the string.
03-25-2010 10:55 AM
Thank you, it works well.
03-25-2010 11:23 AM - edited 03-25-2010 11:26 AM
I don't understand tbobs solution, because it assumes that the input string is in hex formatted normal display while the original problem stated that the input is in hex display. Big difference! (I also don't see why it needs a 100ms wait in the loop, but maybe I am just impatient ;))
Assuming the input is a binary string set to hex display and you want the output hexadecimally formatted as normal display with a space between each octet, you could do something like the following. I don't think you need to worry about the final space. Do you?
03-25-2010 11:38 AM
altenbach wrote:I don't understand tbobs solution, because it assumes that the input string is in hex formatted normal display while the original problem stated that the input is in hex display. Big difference! (I also don't see why it needs a 100ms wait in the loop, but maybe I am just impatient ;))
I didn't notice that the input was a string set to hex display. I thought it was a regular string. As for the time delay, that is my standard practice for all loops to not hog the CPU, unless it is very time critical.
03-25-2010 11:41 AM
You have the string control set the “Hex display” and that may be confusing some of us as to what the actual input data is.
And what you want your output to look like. Do you get a “stream” of bytes that are the actual numbers in the form of a string?orDo you get a “string” of ASCII char that represent numbers?
These are two different things, but may look alike depending on the display setting of your controls are set.
Changing the display mode of a control or indicator does not change the under lying data. It only changes the way your eye “see” it, not how LabVIEW “sees” it.We need to know what your raw input string looks like.
tbob's snipit assume your data is one way and your VI assumes another.
Omar