LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting elements of a string or array by mark value

Solved!
Go to solution

Hello all.

I'm trying since a few days to make an VI which sort my elements in 3 byte arrays.

I receive by serial a string of characters and and my purpose is to obtain 3 byte arrays from the elements received.

The string that i received, converted in hex bytes is of this shape: FF byte1 byte2 byte3 FF byte1 byte2 byte3 FF ....

I need to obtain three array with the elements of byte1 / byte2 / byte3. I use FF as a delimiter between a series of 3 bytes. I tried using an match pattern on the string by the FF corresponding character, but in the end the data are mixed in the arrays.(i don't know why)

Can anyone have a solution for this? Is there a possibility for sorting the array of bytes, not on the string?

Thanks.

0 Kudos
Message 1 of 8
(2,765 Views)
Solution
Accepted by topic author Voda

Hi Voda,

 

see this:

check.png

Only append to the output array when there are exactly 3 bytes.

Switch the string constant to "hex display"…

Use BuildArray instead of InsertIntoArray…

No need to compare with an empty string…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(2,735 Views)

Use reshape array to give you a 4 column X row array.  Then just do an array subset for the 2nd, 3rd, and 4th columns, since the FF's fill be filling the first column.

Message 3 of 8
(2,733 Views)

I don't know if this fits the OP's requirement. This will output the data array for any number of bytes between the FF delimiters.

 

 

alt method.png

 

fp.PNG

0 Kudos
Message 4 of 8
(2,692 Views)

Was thinking that if you need exactly 3 bytes, you could change it to a conditional tunnel

 

alt method with 3 bytes.png

0 Kudos
Message 5 of 8
(2,690 Views)

The flaw is that all rows will be padded to the longest row.

0 Kudos
Message 6 of 8
(2,685 Views)

@altenbach wrote:

The flaw is that all rows will be padded to the longest row.


I beleive my second post fixes the flaw of zero padding the array to the longest row.

 

My way may not be the best way, But to me it just seems GerdW's code is a little convoluted using a case structure, build array, and shift registers when a conditional tunnel is all that is needed.

0 Kudos
Message 7 of 8
(2,676 Views)

Hi Jamiva,

 

But to me it just seems GerdW's code is a little convoluted using a case structure, build array, and shift registers when a conditional tunnel is all that is needed.

I made that example using LV2011: no conditional tunnels…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 8
(2,665 Views)