LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to break a string!!

I don't think you need any "e", you just need to make sure that you only process complete pairs. Then simply retain the leftover string (e.g. in a shift register) for the next iteration and prepend it to the new string.
Message 11 of 34
(1,875 Views)
I'm facing the same problem still. I used both methods attached in GetXY.vi. My problem with serial read is sometiems when visa should read whole of packet x233y34 like that at once. It just reads x23 or x233 and dumps the y34 part. Idunno how it happens and hence it becomes a bit problematic.
Im attaching my whole vi...can you just go through the extreme right part of my vi in the while loop...where I'm doing serial Visa read and scan the data string....
Looking for help
0 Kudos
Message 12 of 34
(1,854 Views)

So if you took the part that comes after the last "x" in one read and appended it to the beginning of the string you get from the next read, would you get a complete datapoint? If so, do that. If not, assume that you can't trust the validity of the first element and the last element of each read and delete them.

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 13 of 34
(1,851 Views)
Hi mike,
I'm unable to find a permanent solution to this problem
When I should receive a string of say x45y65 ... sometimes I get only x sometimes x34 or sometimes x3(when actually string is x34...) whereas sometimes I get full correct string x23y45. I'm wondering where the data gets lost.!!Smiley Surprised  and athe string indicator reads just a blank!
Can you help me figure it out...
0 Kudos
Message 14 of 34
(1,820 Views)
Can you post a complete string showing the problem? Have you tried the experiment that I suggested in your last post?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 15 of 34
(1,816 Views)
What you told in the last post doesnt happen...the data is just lost...
I mean when I read just x and when Visa does the read next time...data of previous iterations is lost and what I get is the new data. I mean position is lost and it just reads just 0,0.
like if Im supposed to get:
x23y34
x24y35
x25y36
x26y37
I get sometimes
x23y34              //correct
x                       //faulty
x25y36                       //correct one
x26y3          //faulty
x27y38                     //this is correct one
x28y39                 //correcct
x29           //faulty
---
i hope you got my problem...
Waiting for your reply


0 Kudos
Message 16 of 34
(1,810 Views)
There seems to be no easy way to tell with 100% certainty if data is faulty. Here you assume that each number is 2 digits, but in the earlier posts you also had 3 digit numbers.
 
x234y236x233y23x238y34
 
For example if you would get x234y23, you would have no good way of telling if it is correct (really x234y23) or incorrect ( really x234y236).
0 Kudos
Message 17 of 34
(1,801 Views)
Are you now saying that the serial port does not get all the data? If you keep a partial dataset from one read (45y6) and append the next read (8x32y61x) to it, do you get 45y68x32y61x?

An earlier post in the thread pointed out that you need to retain the residual partial strings after decoding the available complete x, y pairs until more bytes have been recieved.

This is a common problem with devices which do not terminate each message with a unique character. In fact for your format you will always have an incomplete data set or uncertainty that the last y value is complete unless you know the maximum number of characters a y value can have AND the last data point includes that number of charcters. For example x3y5 may be complete or it may be the first part of x3y54 or x3y547. You do not know until a timeout occurs or the next x arrives.

Lynn
0 Kudos
Message 18 of 34
(1,801 Views)
Yeah, That's correct that has been the problem for me.
You mean to say after x23y45 I can pass an end character like e to make sure that data has been received fully?
like x23y56ex24y55e...keep reading from the visa till I receive an e  and than process the string x23y45e. This way I can set boundry for the data?
Will that be of any help?
Looking for reply
0 Kudos
Message 19 of 34
(1,794 Views)
Yes. If you have control over the protocol used by the sending device, that is the ideal solution. Put all received characters into a shift register in the order received. Search the string for a group of characters bounded by an x and an e. The string between, for example 34y56, is the complete data for one point. Remove the string representing the complete point, including the x and e characters from the shift register and repeat the search. If you get a string which starts with x but has no e, then you know it is not complete and you wait for more bytes from the serial port before converting to numbers.

Lynn
0 Kudos
Message 20 of 34
(1,789 Views)