Jump to content

char array to LabVIEW


Recommended Posts

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.post-9853-0-89905300-1313185930_thumb.jp

Link to comment

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.post-9853-0-89905300-1313185930_thumb.jp

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 by Ton Plomp
Link to comment

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.

  • Like 1
Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.