This widget could not be displayed.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hex string to number or array

Solved!
Go to solution

I have in 2 different traffic generators the input of source and destination address.

I need to read from a .txt file the desired addresses and then configure the generators. I want that the typed address in the .txt file will be in the same format as you can view in the generator interface (thats what I cant change)

The problem is that each one of them is using different arrays formats as input to the function, and I would like to read from the .txt file as a string.

For the first one at the moment I am doing like this:

1_string2array.png

and as I result, and is right, I have the array 0-0-0-0-0-3:

1_string2array.png

 

For the second one, when I type directly into the generator the address 00-00-00-00-00-22 , I will get on Labview an array 0-0-0-0-0-34, that I am converting to number as below:

as a result:

4_array2number.png

So, how can I convert 5_string.png, that will be typed in the .txt file, into the array above?

 

Thanks and I hope to be possible to understand what I need 🙂

 

0 Kudos
Message 1 of 13
(4,147 Views)

If you attach your code, we can understand better what you mean. At the moment, your problem is unclear.

 

Cameron

 

Wow! fast service...Smiley Very Happy

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 2 of 13
(4,143 Views)

are you sure? I was thinking that would be more confusing my code 🙂

 

Here we go.

 

String to array works fine for the first generator.

 

Pase packet is for the second one. Where you maybe can see the format of the desired address.

Download All
0 Kudos
Message 3 of 13
(4,135 Views)

in Parse Packet:

 

"data" comes from the analisys of the traffic generator

"dst address" and "src address" comes from the .txt file.

 

I need to compare them and they need to be the same. But the difference of formats is not allowing this.

0 Kudos
Message 4 of 13
(4,131 Views)

***EDITED***

 

Oh sorry. I didn't read properly.  I'll make a modification here Smiley Frustrated

0 Kudos
Message 5 of 13
(4,107 Views)

I cant follow the code logic for the Parse Packet VI (so no help there) but thought I could shorten the string to array VI...

While there is nothing wrong with it, I thought it was a little long for the conversion you were doing.

 

2013-08-09 09_00_42-Untitled 1 Block Diagram _.png

0 Kudos
Message 6 of 13
(4,085 Views)

sorry but is not like this yet. this returns me an array 000000000022.

In my input I have 34 as shown above. This comparison still is different.

0 Kudos
Message 7 of 13
(4,056 Views)
Solution
Accepted by topic author tmarques

OK, so see if I understand you correctly.

 

What you want to do is take the 12-digit MAC address strings (that you have already pulled from your .txt file) and convert them into 6-member numerical arrays?

 

If so, this will do that (once for each MAC address):

 

string.png

 

Now, there may be (probably are) other ways, and this may not be (probably isn't) the most efficient way to do it, but it will work.

 

TIMTOWTDI.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
Message 8 of 13
(4,054 Views)

thanks!!

it works fine 🙂

0 Kudos
Message 9 of 13
(4,016 Views)

Hi tmarques,

 

now without loops:

check.png

 

When you need that loop you could use more simple string functions:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 13
(4,011 Views)