08-23-2007 04:08 PM
08-23-2007 04:29 PM
The closest Labview equivalent to a C structure is the Labview cluster. However, they are not exactly interchangeable. There are limitations. I have successfully passed LV clusters into a C structure once before but the data elements were simple numerics and a fixed length string.
If you would describe the structure, one of us may be able to help you. If it is not practical to create a cluster which is equivalent to the structure, you will have write some wrapper code in C to transform the structure into individual elements and vice versa.
08-23-2007 06:39 PM
Blog for (mostly LabVIEW) programmers: Tips And Tricks
08-23-2007 09:42 PM
08-24-2007 02:21 AM
08-24-2007 03:14 AM - edited 08-24-2007 03:14 AM
Hi Grelf,
Any chance of your posting the actual binary data? I'm curious about how the array-data is packed. It looks like there's an extra 8 bytes with both the sRate and sTime arrays. If both those lengths are really 64 (no structural info) then with a little fudging you can probably cast the binary string straight into a structure - I mean cluster. I was thinking about reversing the byte-order of the binary-string to take care of endian-ness all at once, and creating 8-element clusters for each of the arrays. There might be some byte-padding issues with the chars, maybe not, either way it seems promising.
Cheers!
Message Edited by tbd on 08-24-2007 03:15 AM
08-24-2007 07:24 AM
the C code would do all the byte-swapping, and construct a LabVIEW string from a C string.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
08-24-2007 11:08 AM
Tbd - point taken with the extra bytes - The data that comes from the TCP/Ip or UDP packet is nothing more then a string of bytes that fill the packet that is sent. It is up to the end use to decipher what those bytes really mean. Within a C structure this is a simple task since we point to a memory location that holds the sent packet. Based on the inputs that I have been receiving it seems that one can store the infor within an array (byte) then extract the bytes as needed ( byte swap etc) and then send to a cluster- sounds painful indeed or write a c program that translates a packet string of data into a cluster which is basically the same. It does sound like what would be nice is if the cluster could point to the memory location of where the data lies and extract according to what the elements are within the cluster. A cluster that can reference a memory location (just a thought that popped out) - thanks for the inputs, time to try a few of them and see what happens unless someone knows of a way to reference a memory location.
GG
08-24-2007 11:49 AM - edited 08-24-2007 11:49 AM
Message Edited by tbob on 08-24-2007 09:50 AM
08-24-2007 05:44 PM - edited 08-24-2007 05:44 PM
Hi Greif,
Without some data to practice with, I'm not as confident that this will work, but if endian-ness is applicable uniformly (that is, all data-types are byte-swapped LSB to MSB) and if MAX is always 256, and if STREAMS is always 8, then the solution might be as simple as this:
The [nested] clusters (sRate/sTime and Name) can be cast-back to arrays or strings in LabVIEW.
Cheers:
Message Edited by tbd on 08-24-2007 05:48 PM