11-25-2020 05:36 PM
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.
11-25-2020 10:36 PM - edited 11-25-2020 10:47 PM
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." |
11-30-2020 07:15 AM
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.
11-30-2020 09:25 AM
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
11-30-2020 10:12 AM - edited 11-30-2020 10:26 AM
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.
11-30-2020 10:56 AM
Thank you Rolf. This was very helpful...