LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to select the last elements in a string

Solved!
Go to solution

Hello crossrulz

 

7B 7B and 7D 7D indicate the begining and end of the frame respectivelly. In other VI i identify that charaters and eliminate. My problem is how i manipulate the data. The data arrive in decimal and i must sum all data to verify the checksum. I'm not able to get that. I think that i must convert dec to hex and in the end convert to double to apply expressions that i must work with. I think that you understand my doubt but i can get it. Even with your and other examples it doesn't work.

 

Thank you very much for all the support 

0 Kudos
Message 11 of 23
(2,374 Views)

My code assumes the {{ and }} are still there.  If those are already removed, then it becomes a lot simpler.  You can just use Delete From Array on your byte array.  Do not wire the index or size.  It defaults to deleting the last element, which just happens to be your checksum.  So then use Add Array Elements on the output array and you can then compare it to the deleted element.


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 12 of 23
(2,369 Views)

Here, this will parse your entire message, including the casting to double precision floating point numbers.  Though, I question if your data are Big Endian or Little Endian (makes a huge difference in your data).

 

The Decimal vs Hexidecimal is just how the data is viewed.  The data itself is not changing.  I just find Hex easier to look at, especially since we are talking about the bytes.


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 13 of 23
(2,362 Views)

Hello again

 

Look in the example in the attachment. I made equal but sum and CKS are not equal. Plus, The VI works if i converte previously the decimal data to hex and then paste it in my string indicator. 

0 Kudos
Message 14 of 23
(2,347 Views)

You are missing some data in your string.

7B7B A036 6F67 6E6C 6B6D 6C6C 6464 6464 0000 0104 0500 0000 0000 0007 6001 0000 0000 000A 3301 0000 3301 0117 0C00 CE7D 7D


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 15 of 23
(2,332 Views)
Solution
Accepted by RuiZanzibar

Hi guys

This is how i made and work perfectly!

 

Thanks to all

0 Kudos
Message 16 of 23
(2,195 Views)

You have some real Rube Goldbergs in there.

 

1.  No need to figure out the index of the last element of the array.  If you leave the index of the Delete From Array unwired, it automatically deletes the last element.

2.  No need to even use Array Index in order to get the CRC out of the array.  The Delete From Array has a second output called Deleted Element.

3.  I have no clue why you are converting the U8 into a string just to take it back to a U8.  What's wrong with just comparing the sumation directly?


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 17 of 23
(2,186 Views)

Hi there

 

The CKS isn't always the same value! The brodcaste is diferent too. The data is on ASCII and i need the value of CKS to compare and the length is 255 bytes hence the U8 representation. The index from delete from array is n-1 (CKS) that i have to remove and then compare with the sume of the string without the CKS in the frame, that is a condition that I have to obey.

0 Kudos
Message 18 of 23
(2,174 Views)

RuiZanzibar wrote:  The index from delete from array is n-1 (CKS) that i have to remove and then compare with the sume of the string without the CKS in the frame, that is a condition that I have to obey.

Yeah, that is the last element.  It would be the exact same if you left the index unwired.


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 19 of 23
(2,159 Views)

Hello

 

I forgot to tell that i have a start (7B7B) and end (7D7D) frame in the broadcast, thats why the index must be (n-1). 

Hugs

0 Kudos
Message 20 of 23
(2,130 Views)