The problem here is that at the receiving end, one cannot know how many
bytes to read before unflattenning into the datatype.
A method that works for *any* datatype (and any data transfer mechanism):
Flatten the data to string.
Flatten again the string to string; this adds a string lenght (U32) header
to the string.
Send the string.
When receiving data, first read 4 bytes and convert to U32.
Read this number of bytes.
Typecast the string to the expected datatype.
Jean-Pierre Drolet
----- Message d'origine -----
De : "Mark Hanning-Lee"
Groupes de discussion : comp.lang.labview
Envoye : 6 septembre, 2001 22:21
Objet : Re: How do I read/write many matrices through TCP server?
> Lab Viewer wrote:
> >
> > Hi Irene,
> > Re
garding that example, probably you are wondering how can you pass a
> > 2D array to Type Cast.VI (it accept only 1D array). The answer is
> > Reshape Array.VI. Use this VI to transform your multidimensional array
> > in a 1D array (after that use Type Cast.VI to transform it in a
> > string). Also, you can use Array To Spreadsheet String.VI in order to
> > obtain a string to send via TCP, but in this case the string is
> > longer.
>
> Or better, wire the 2D array to the Flatten to String function, which
> accepts any data type.
>
> When you receive the data, wire the string into the Unflatten from
> String function. You'll need to wire a 2D array of the same
> representation into the type input of that function.
>
> Mark