Discussion:
Read Serial Data
(too old to reply)
ritesh024
2008-08-09 12:40:05 UTC
Permalink
Dear All, I am reading data from serial port which the VISA read function stores in a string buffer. is dere any way by which i can store the data in a string array as i want to access the data in bytes separately?? Thanks Ritesh
drewsky
2008-08-09 13:10:05 UTC
Permalink
You can acess each character seperately if you wire the string into a for loop and enable indexing.
cschneider
2008-08-09 13:40:05 UTC
Permalink
Hi drewsky!This solution was new for me, so I tried to wire a string into a for-loop, but I can't enable indexing (top of image). Can you specify what you mean? Do you mean a solution as showed on the bottom of the image??<img src="Loading Image..."> Greetings,ChristianMessage Edited by cschneider on 08-09-2008 04:40 PM


string1.png:
http://forums.ni.com/attachments/ni/170/348045/1/string1.png
drewsky
2008-08-09 19:10:05 UTC
Permalink
Yeah that's what I meant.&nbsp; I don't have LV on this comp, so I didn't try it ahead of time. :smileysad: Will that work for you?
MKES
2008-08-10 13:10:04 UTC
Permalink
Is this what want to do ?


String to array.vi:
http://forums.ni.com/attachments/ni/170/348097/1/String to array.vi
ShotSimon
2008-08-10 23:40:05 UTC
Permalink
ritesh024,
&nbsp;
You can enable indexing into and out of&nbsp;a FOR LOOP by right clicking on the input/output box at the boundary of the FOR LOOP.&nbsp; In your case&nbsp;in the top FOR LOOP the pink incoming box.&nbsp; Regards,&nbsp; -SS
drewsky
2008-08-11 00:40:04 UTC
Permalink
that's what I thought too, but I just tried it, and it won't allow it.&nbsp; The software I am using right now is beta, so I could be wrong...&nbsp; I'll double check at the office tomorrow...
ShotSimon
2008-08-11 00:40:05 UTC
Permalink
LabVIEW 64-bit beta?&nbsp; -SS
drewsky
2008-08-11 00:40:05 UTC
Permalink
yeah
ritesh024
2008-08-11 13:40:07 UTC
Permalink
Thanks alot guys for your help. That for loop solution works gr8.and one more thing .. you cant do auto indexing for a string in for loop. you can only do it for an array.. so, u need to break the string into substrings for storing a string into array ..Ritesh
ShotSimon
2008-08-11 14:40:10 UTC
Permalink
ritesh024,
That is very interesting since a string in C programming is a one-dimensional array of type char, with a \0 termination?&nbsp; I never noticed that LabVIEW is different in this regard.
Thanks for pointing that out with such a simple example:smileyvery-happy:&nbsp;-SS
MKES
2008-08-11 15:10:06 UTC
Permalink
Hi !
&nbsp;
Here you have another one using less code than my previous post... it's added to that one for you to compare.
&nbsp;
:robotwink:


String to array1.vi:
http://forums.ni.com/attachments/ni/170/348280/1/String to array1.vi
drewsky
2008-08-11 15:40:06 UTC
Permalink
I don't know if it matters, but looking at the VI MKES posted, I did a quick performance test.&nbsp; As expected the String subset appears to be slightly faster, but of course to see that requires a long string and a lot of iterations.&nbsp; Food for thought if you have a ton of strings to process this way.
Continue reading on narkive:
Loading...