LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to check info in string read from com port

This is a redundant question that numerous people have asked, but it is one that I need help with. If I need to read data streaming in through a serial port and check all the data coming in, what is the best way to do this. I need help with the order of operations. Ex. Do I implement a loop while data is streaming in saving all data to an array of some fixed length and do I check the array of data to see if the data I need is there and if it's not, do I flush the data and read in the next n size data into the array and check that? Then break out of the loop when the data has been found? Or should I install a com callback? Will the program run fast enough that I will be able to acquire all the data in the array without missing s
ome?
0 Kudos
Message 1 of 2
(2,437 Views)
Hi,

The best mechanism to program a serial application usually depends on the way the data is coming in. If you have a stream of data that has a termination character after each message, it would be easy to set a callback, set the termination character and parse the data in every callback.

If the data is just streaming with any specific termination you can set a loop that checks for the beginning of the string and if it is find it acquires and concatenates the required number of bytes; when the string is complete you run the parsing routine.

In general Callbacks can keep up with the rate, I would recommend that you take a look at how the data is coming, and start with a callback based app; in most cases this should be fast enough.

Please let me know i
f you have any further questions on this.

regards,

Juan Carlos
N.I.
0 Kudos
Message 2 of 2
(2,437 Views)