LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling execution by scanning a string

Can anyone tell/show me how I can control the execution of a loop by scanning an incoming serial data stream for and ascii "READY". I am currently inside a while loop to continue reading my data in off of a serial port, and at the end of my test, "READY" is appended onto my data to let me know that the transfer is complete, but I don't know how to wire my stop button so that whenever the "READY" is recieved, execution of my while loop stops.

thanks in advance
0 Kudos
Message 1 of 5
(2,956 Views)
That depends on how you're reading. You say you're using a while loop to read continuosly. How many bytes do you read in each iteration. Do you concatenate the strings to get one long string?
I'll assume that you do concatenation. In this case, you can either search the string for "READY" (using search/split string) and use Not equal to -1 to stop the loop;
or you can use string length and string subset to read the last 5 letters and compare them to READY;
or you can look for R and if found look for the rest;
or you can scan only the incoming string;
or you can try reading the entire string at once;
or
or
or...

As you can see, there are many options. It mainly depends on how you're reading.
If this didn't help you, I suggest you post the relevant piece of code, or at least an image of it (no BMPs, please).

___________________
Try to take over the world!
Message 2 of 5
(2,947 Views)
I will post my .vi either tonight or tomorrow.

thanks
0 Kudos
Message 3 of 5
(2,930 Views)
Here is the .vi that i'm working on. i'm trying to scan the string for READY at the end, and use that to stop execution of my loop. any suggestions/help would be GREATLY appreciated.

thanks,

jimmy
0 Kudos
Message 4 of 5
(2,922 Views)

Here is one example of how this can be done:

The string is concatenated and the search is performed on the entire string (assuming the word only appears once).

This will work, but there are other problems in your VI. For example, the serial timeout is set by default to 10 secs, so after the last pack arrives, it will take a few seconds before the loop stops. Also, your VI is hard to read and you have things which aren't connected to each other (like the config VI or the port number, which is unnecessary). You should clean up the VI so that it will be easier to understand and debug.

To learn more, I suggest you read the LabVIEW user manual. Also, try searching this site and google for LabVIEW tutorials. Here is one you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide.


___________________
Try to take over the world!
Message 5 of 5
(2,908 Views)