LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converted Hex display to Hex formatted normal display not showing leading zeroes

Solved!
Go to solution

Hi All

 

I am trying to combine a Normal Display string indicator with hex

To do this I have formatted the hex into a format where it still looks like the starting hex but can go into the normal display string

 

e.g..

I start with 00040040

 

When I try to put this into my Normal display string I get 40040.

 

I have added a VI with an explanation and example - it'll be much easier to understand if you have a look at that.

 

Thanks for reading

0 Kudos
Message 1 of 12
(4,663 Views)

Number to Hexadecimal string.  There is a width input.  Wire something to that such as a constant of 8.

0 Kudos
Message 2 of 12
(4,658 Views)

I couldn't look at your VI, but did you try the "Number To Hexadecimal String" with a width of 8?

 

[Edit] guess I'm a bit late.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 12
(4,656 Views)

Will it always be 4 bytes (U32)?  If so, set the width of the To Hex String to 8.


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 4 of 12
(4,655 Views)

Its not that simple sadly - there is data before and after it

I am searching for part of the hex (say 2312) then trying to grab the next 6 bytes after it.
The problem is if the first X = 0, it chops them and adds whatever comes after those 6 bytes to the end

e.g.

 

23120004004012345678

 

So i find 2312
then try to grab the next 6 bytes

i get 4004 0123 5678

0 Kudos
Message 5 of 12
(4,650 Views)

You are going to have to supply some code with this behavior.  Sounds like you have a bug.


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 6 of 12
(4,647 Views)

@NIcurious wrote:

Its not that simple sadly - there is data before and after it

I am searching for part of the hex (say 2312) then trying to grab the next 6 bytes after it.
The problem is if the first X = 0, it chops them and adds whatever comes after those 6 bytes to the end

e.g.

 

23120004004012345678

 

So i find 2312
then try to grab the next 6 bytes

i get 4004 0123 5678


Show us your code, your description is not clear at all.

 

What are the display formats of the various strings?

I cannot find a string function called "grab".

 

0 Kudos
Message 7 of 12
(4,645 Views)

1. I use the search node to find the index of 1256

2. I get use the unflatten from string to get the decimal followed by a number to hex function with a width of 6 (I want 48 bytes)

 

Here if my string begins with X number of zeroes those zeroes are not included

 

e.g.

Hex string 00041122334455667788 becomes

 

41122334455

 

Byte 1

4

Byte 2

11

byte 3

22

byte 4

33

byte 5

44

byte 6

55

 

 

 

It should be

byte 1

00

byte 2

04

etc

 

 

 

Can't post the code cause its huge and the string is past in from another VI

Hope you'ev got enough detail here

0 Kudos
Message 8 of 12
(4,635 Views)

@NIcurious wrote:

Can't post the code cause its huge and the string is past in from another VI


Then create a new VI containing only the relevant code. You can make the "string" a diagram constant containing exactly what is received from elsewhere.

0 Kudos
Message 9 of 12
(4,631 Views)

Overall, I think you are making this far more complicated than it should be by taking some string data, unflattening it from a string (what did it originally look like coming in?) then turning it into a hex formatted string and manipulating characters.

 

You should be able to work with bytes more directly.  Turn your strings into arrays of U8 integers and work with them.  Then you shouldn't have to worry about leading zeroes in a hex formatted string and whether they should or shouldn't be there, and if they are there or not because you have undetermined lengths of data.

 

String to Byte Array, and Typecast are probably the functions you should be using rather than the ones you are.

0 Kudos
Message 10 of 12
(4,627 Views)