the question isn't how to detect the end of a receive stream it is how do I stop a loop that sends commands to the TSA from incrementing on until I the eof from the NewData sub has been received.
Did you get this working to do what you need done?
I feel that if you only send the next command when you "detect the end of a receive stream" of the response to the previous command, with a watchdog timer to restart the communication "conversation" if it has died for some reason (serial data interruption, TSA rebooted, app restarted, etc) then it should work fine.
This is assuming that, at the end of each response, the TSA sends a "command prompt" to indicate it is ready for the next command.
The command prompt being 4 bytes with values: 10 (linefeed) 93 (lowercase c) 114 (lowercase r) and 62 (greater than).
I suspect that the overlap of the last byte (linefeed) of the previous response being the first byte (linefeed) of the command prompt is where most usual parsing styles might trip up, especially at TSA startup (eg no leading linefeed issued, just the 93, 114 and 62 bytes) or if there is noise on the serial line after the end of the previous response (eg receive previous response data bytes, 10, random noise bytes, 92, 114, 62).
But I also think that those situations would be rare, and would be quickly resolved by the watchdog timer, assuming that there are no large gaps or delays in the TSA's responses (because the watchdog period would need to be set to the longest of those gaps or delays).
If you're suffering burnout on this topic and your eyes are glazing over as you read this, then have a break from it (if you can) and then I'd be happy to go through implementing it with you afresh. Admittedly it was 15 years ago now, but I spent more than a decade interfacing to automotive test equipment, gas analysers, data acquisition systems, online parts ordering portals, etc, all via RS232. Lol prior to that, I was scraping stock prices off MoneyWatch (CommBank's pre-internet Viatel service at 1200/75 baud) and before that, using VK100 terminal (that had inbuilt BASIC) to emulate a (very fast) operator to a VAX minicomputer. Lol, those were the days.