I'm embarrassed to say that I've been using the CVI RS232 library for some time now, across multiple projects, but only now getting a fuller picture of how the thing works. And I have some fundamental misunderstandings of the beast that I'm hoping all you wonderful people can clear up for me.
I have a new project with a device that talks at 115200 baud. It has one particular mode which spits out data dumps continuously. It's up to me to turn off this mode after a sufficient number of samples have been taken (~400). This number of samples equates to 18,800 bytes. No problem -- on my Win 7 machine and serial port hardware, I have plenty of space in my queue.
So I set up an InstallComCallback with this buffer size in mind. My thinking is, capture the whole block first, then read it out of the queue at a leisure pace offline.
The ComCallback fires as expected. Immediately, I do a
qBytes = GetInQLen(port);
Consistently, I get qBytes = 19840 (not sure why it's more than expected, but whatevs. Then inside the ComCallback, I execute a series of ComRdByte calls.
Here is where I was getting -99 timeout errors. So Right before the ComRdByte, I did another GetInQLen. I get a different value now, considerably less.
I guess my misunderstanding is this: how robust is the com buffer? Can I not depend on that data being there for later when I need it?