rk1960in Posted August 12, 2011 Report Share Posted August 12, 2011 When trying to pass the char array of 260bytes, unflatten from string does not return the all 260 bytes. In the attached VI after unflatten from string reads only 4 bytes, does anyone know why? Is there any other method to allocate string size in LabVIEW to read 260 bytes of char? In C the array is char ProjectName[260]; TIA. Quote Link to comment
Ton Plomp Posted August 12, 2011 Report Share Posted August 12, 2011 (edited) When trying to pass the char array of 260bytes, unflatten from string does not return the all 260 bytes. In the attached VI after unflatten from string reads only 4 bytes, does anyone know why? Is there any other method to allocate string size in LabVIEW to read 260 bytes of char? In C the array is char ProjectName[260]; TIA. Most likely you use the wrong command, have a look at the 'String to [u8]' function, your function checks the embedded length (like a c-string pascal-string), but your string probably misses that info. Ton Edited August 13, 2011 by Ton Plomp Quote Link to comment
ned Posted August 12, 2011 Report Share Posted August 12, 2011 All the U8 array manipulation is useless. The type input to Unflatten From String just needs the datatype - string, in your case - and the actual length and content of that string is irrelevant. What are you trying to get out of this? If you just need the first 260 elements in the string, then use string subset. There's no reason to unflatten a string from a string; the flattened form of a string is just the same string, with the length preprended. If you're getting that data from C then the length information isn't there, which will prevent LabVIEW from unflattening it correctly. 1 Quote Link to comment
rk1960in Posted August 13, 2011 Author Report Share Posted August 13, 2011 Thanks all, string subset function helped me to extract out the data. All the U8 array manipulation is useless. The type input to Unflatten From String just needs the datatype - string, in your case - and the actual length and content of that string is irrelevant. What are you trying to get out of this? If you just need the first 260 elements in the string, then use string subset. There's no reason to unflatten a string from a string; the flattened form of a string is just the same string, with the length preprended. If you're getting that data from C then the length information isn't there, which will prevent LabVIEW from unflattening it correctly. 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.