Umit Uzun Posted April 22, 2009 Report Share Posted April 22, 2009 Hi All; I have a separated projects in c++ and labview and which have to share dynamically created data each other. I have tried socket usage on UDP and can send string data via socket from Labview to c++ app. But I don't know how can I pass cluster (in c++ struct) data from labview. Could anyone show me or give me any reference about kind of these operations to make me achieve? Thanks in advance. Umit Uzun Quote Link to comment
Mark Smith Posted April 22, 2009 Report Share Posted April 22, 2009 QUOTE (Umit Uzun @ Apr 21 2009, 02:44 AM) Hi All;I have a separated projects in c++ and labview and which have to share dynamically created data each other. I have tried socket usage on UDP and can send string data via socket from Labview to c++ app. But I don't know how can I pass cluster (in c++ struct) data from labview. Could anyone show me or give me any reference about kind of these operations to make me achieve? Thanks in advance. Umit Uzun Use the LabVIEW "Flatten to String" function - this will serialize a LabVIEW data cluster into a byte stream that can then be unpacked by the C++ app into a C++ struct - for example LabVIEW cluster: Numeric (Double), Numeric (U32 Int), Array (U16) (note that this must be a populated array of the same size as the target struct) to pass this to a struct of struct LVData { double x; int y; short array[100]; }; Then just wire the cluster up to flatten to string (wire a false constant into the "prepend array or string size? " control) and then pass the flattened string to your C++ app. Now that app will have to deserialize into a struct. Mark Quote Link to comment
Umit Uzun Posted April 22, 2009 Author Report Share Posted April 22, 2009 QUOTE (mesmith @ Apr 21 2009, 03:40 PM) Use the LabVIEW "Flatten to String" function - this will serialize a LabVIEW data cluster into a byte stream that can then be unpacked by the C++ app into a C++ struct - for exampleLabVIEW cluster: Numeric (Double), Numeric (U32 Int), Array (U16) (note that this must be a populated array of the same size as the target struct) to pass this to a struct of struct LVData { double x; int y; short array[100]; }; Then just wire the cluster up to flatten to string (wire a false constant into the "prepend array or string size? " control) and then pass the flattened string to your C++ app. Now that app will have to deserialize into a struct. Mark Hi Mark; Thanks so much. I have resolved the problem with your awesome directions :thumbup: Best Regards. Umit Uzun Quote Link to comment
PaulL Posted April 22, 2009 Report Share Posted April 22, 2009 You could also serialize the cluster using XML (JKI's EasyXML does serialize clusters well), which might make deserialization on the C++ side more straightforward. This is supposedly a common application of XML. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.