Hi,
I would suggest reading the whole string first before parsing. I/O is expensive and it is best to transfer as much data in a single shot as possible (DMA vs. Polling is an example). Read the whole string in and then parse. In the end this will both be faster and more elegant.
Best Regards,
Aaron K.
Application Engineer
National Instruments