LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP message not working

I created a TCP message but it doesn't work with my device and I think I may have coded it wrongly. Below is an outline of the spec.

 

Data      Bit count   Data Type

Data1       16          Unsigned Integer

Data2       16          Unsigned Integer

Data3       16          Unsigned Integer

Data3        88         String (11bytes)

Data4         8           N/A (multiple of 16 bits pad)

 

I've attached my sample code and data. I've attached two WireShark data screenshots, one for the correct data and the other for the incorrect data from my code.  I'm not really sure what I was doing wrong perhaps interpreting the spec wrongly.

Any inputs and suggestions are welcome.

Thanks in advance.

0 Kudos
Message 1 of 6
(1,735 Views)

Your list doesn't make sense.   You have data3 listed twice, once as a U16, another as an 11 byte string.

Your data4 is 8-bit, but you call it N/A and "Multiple of 16 bits pad".   Multiple?  16 bits?  that  is more than than 8.

 

Your VI seems okay with U16 for data 1 2 and 3.   (at least the first Data3).  Your Data4 is a string of undefined length.  Your "pad" looks like the 2nd data3, set as 11 bytes of spaces, but that looks like your description for your 2nd data3.  So it makes it seem like your cluster may be defined in a different order near the end.

 

It seems that the extra bytes of 00 00 00 0B is the string size for the 11 by Despite have a F wired to Prepend string size, it will still include the string size that is within the cluster.  Read the context help to Flatten to String.  It says "

prepend array or string size? only controls the top-level data size information. Arrays and strings in hierarchical data types such as clusters always include size information."

Don't build a cluster and flatten that.  Manually handle each part typecasting the values to strings, concatenating the results, and making sure things like you 11 byte string are 11 bytes no matter what you type into controls.
0 Kudos
Message 2 of 6
(1,707 Views)

RavensFan,

Thanks for your response. My apologies, the second data3 was a typo. It should be data4 and data4 on the list should be data5. Regarding the 8bit designation for data4(data5) which was described as a multiple of 16bits. That was what I saw on the spec and I found it a bit confusing as well. Thanks for pointing that out. I will make changes based on your comments below to see what happens.

 

0 Kudos
Message 3 of 6
(1,678 Views)

RavensFan, 

Can you explain how to handle the header information in the flatten to string more clearly. How do I eliminate the header information given that I need to send out the data in a cluster? A simple example will help tremendously.

Thanks

0 Kudos
Message 4 of 6
(1,667 Views)

flatten.png

The cluster only contains the first three integers. LabVIEW strings need to be "flattened" differently. No need to make the padding part of the interface, simply generate it in the VI.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 5 of 6
(1,660 Views)

Thank you Rolf. This was very helpful...

0 Kudos
Message 6 of 6
(1,651 Views)