01-26-2006 11:58 AM
01-26-2006 01:41 PM
01-26-2006 02:00 PM - edited 01-26-2006 02:00 PM
One way or another, LabVIEW needs to know the string lenght.
One possibility would be to dissect the raw string manually with some custom code instead of using a plain unflatten operation. The attached (LabVIEW 8.0) would be one possibility).
Message Edited by altenbach on 01-26-2006 12:13 PM
01-26-2006 05:28 PM
01-26-2006 05:54 PM
Thanks for the suggestions, I did not know that C++ placed a null character at the end of a string.
The assumption is that I fully know the definition of the binary string that comes from the C++ app. The problem, fundamentally, comes from the fact that strings (and arrays) are of indeterminate length. The preferred solution is for the Unflatten From String VI to "ask" the user for the length information when populating a cluster with an indeterminate data type such as a string or array.
Up till now, I have been inserting a 4 byte integer containing the length of the string into the binary string immediately before the output string (Labview stores strings in memory with a four byte header indicating the length). This allows Labview to properly load the binary string into the cluster (if the header is not there, labview assumes the first four bytes of my string are the header). This is awkward. I maintain a cluster definition (a custom control that is a typedef). I just want to unflatten the incoming binary string using the typedef cluster. We are frequently revising the cluster and this means that in addition to modifying my custom control, I have also to modify the insert string code.
Any more suggestions?
01-26-2006 10:35 PM - edited 01-26-2006 10:35 PM
Message Edité par Jean-Pierre Drolet le 01-26-2006 11:41 PM
LabVIEW, C'est LabVIEW
01-27-2006 07:12 AM
LabVIEW, C'est LabVIEW
01-27-2006 09:00 AM
Hi Jean Pierre,
Thanks for your response. Labview 8 offers and even easier way to unflatten a string than what you show in your second example. One of the inputs for the Unflatten from String VI is, “Data Includes Array or String Size (T)”. Wire up a false to this node and the string (or array) does not need the four byte length header.
Also, Labview 8 asks for the endian type, this is a major improvement for me since previous version of Labview assumed big endian and all my data was little endian. I can't tell you how long I had to work to find a solution to the problem.
Thank you,
Chris
01-28-2006 02:47 PM
LabVIEW, C'est LabVIEW