Content originally posted in LPCWare by Tsuneo on Fri Jul 27 02:48:36 MST 2012
Quote:
Now I want to reset the Endpoint In buffer before i restart the aquisition. I use the "Clear Buffer" command from the USB command code.
Do you mean you've applied "Clear Buffer" SIE command to the bulk IN endpoint?
This command is supposed just for OUT endpoints.
CDC-ACM class driver on PC of major OS (Windows, Linux and MacOSX) always polls bulk IN pipe, regardless that PC application reads RX COM port or not. Therefore, when your firmware stops writing to the bulk IN endpoint, the bulk IN endpoint buffer goes empty within two or three USB frames, even considering of double buffering. You may confirm buffer empty, applying "Select Endpoint" SIE command, at B_1_FULL/B_2_FULL bits.
Rather, you have to flush the input buffer on the PC class driver.
For Windows, Win32 API: PurgeComm( PURGE_RXCLEAR ), .NET: SerialPort.DiscardInBuffer
Tsuneo