1. OPEN_DRIVER_ASYNC() (no problem here)
2. USB_WRITE(mDevice, mpUsbdata) (no problem here)
3. READ_MULTIPLE_SWEEPS(mDevice, mpData, BUFFER_SIZE_IN_BYTES);
According to my understanding, this function tells the machine, "mpData" is the ringbuffer we should work with and "BUFFER_SIZE_IN_BYTES" is the size of the buffer. So from this point, the machine will keep filling this buffer continuously. ( I assume there is a buffer in the machine. And the the data filled in the ringbuffer comes from that buffer inside the machine)
4. READ_POINTER(mDevice, mpBufferCursorPos): when we call this function, the machine will get a pointer, mpBufferCursorPos, points to the address of the last data filled into our ringbuffer.
5. Enable Handshake (no problem here)
6. Disable Handshake (no problem here)
7. Disconnect (no problem here)
This is how I understand the functions. Are there any misunderstanding there?
What I am trying to do now is to fetch the data for specific time. For example, I only want to get the signal when the user presses a key on keyboard. So what I did if call READ_POINTER() once when the we catch a key stroke, and minus the cursor by numberOfDataToBeRead to get the start point of reading data. And then read all the data from the start point to the mpBufferCursorPos(the last new data).
(I did this because I think when the system catch the key stroke event, the data has already been written to the ringbuffer so that maybe I should read the data before mpBufferCursorPos)
The problem I got from the method above:
I can get some data for a while and then all the data is zero! When I say "a while" I think it works for the first round filling ringbuffer, but once the ringbuffer is full for the first time, then the machine start to fill in the ringbuffer from the beginning and that is when I start to get all the zeros.
The only reason I can imagine is that the frequency I call READ_POINTER is too low so that it cause some problems but I am still not sure what it is. I think it may be the problem that the buffer inside the machine is overflowed because of the low frequency of calling READ_POINTER.
I am still want to know where all those zeros come from and does it mean the machine clean the buffer and stop?
Thanks a lot!!!!!
