@WRB wrote:
Hi Bob,
I notice that if I read more frequently than I write, the read yields an empty string array (in my test application, both read and write operations are in their own independent while loops). I assume that once data is read, the buffers holding the data are automatically cleared. To avoid this situation, I could ignore reads when the read yields an empty string array. But, is it possible to sense that data is available before executing a read?
Yes (and no). It depends a bit on your circumstances. I have some data that need to be processed relatively promptly, but that aren't always "present" (I have an "Event" stream that fires when a User presses a Button, a State Machine changes State, a Digital Line goes high or low, etc.). I do the Stream Read with a TimeOut of 500 ms -- if TimeOut is False, there's data in them thar Streams, so I enqueue it to the Consumer of Event Data. Otherwise, I ignore it and go back for another (possible half-second) wait. I get to have my Cake (fast response when data are present) and Eat it, Too (not get "hung up" if data are not present, so I could exit the Loop if necessary, or not have to "spin" checking for the presence of data).
Bob Schor