I can reproduce this easily if I call usb_interrupt_write in a tight loop. I'm sending 13 byte packets with an incrementing sequence number and crc32. My USB sniffer sees two of them go out. If I sleep 4ms between calls to usb_interrupt_write, it can send thousands of packets correctly without sending duplicate data. I've attached a USB trace from TotalPhase
This packet appears twice on OUT
07 00 06 00 09 93 F4 FD
06 B6 27 E5 A6
The USB device is setup to echo every packet it receives.
I'm reading and writing the usb device from different threads. Here is the code for the writer thread (to try to illustrate that it's unlikely/impossible that I'm sending the same packet twice.)
unsigned writer( void * udev_void )
{
struct usb_dev_handle udev = (struct usb_dev_handle)udev_void;
RingBuffer_t tx; uint8_t tx_data[256]; DWORD last_update = timeGetTime(); uint16_t tx_sequence_number = 0; uint16_t sent_since_last_update = 0; Sleep(1000); // wait for the reader thread to get started while(1) { RingBuffer_InitBuffer(&tx,tx_data,sizeof(tx_data)); write_ude_message( &tx, tx_sequence_number, MESSAGE_ID_ECHO_REQUEST, (const uint8_t*)&g_time, sizeof(g_time) ); while ( RingBuffer_GetCount(&tx) ) { int ret = usb_interrupt_write( udev, 4, //epWrite, (char*)tx.Out, RingBuffer_GetCount(&tx), 1000); if ( ret > 0 ) { RingBuffer_Remove_Array(&tx,0,ret); } } tx_sequence_number++; sent_since_last_update++; DWORD elapsed = timeGetTime() - last_update; if ( elapsed > 2000 ) { printf("%i sent (%i)\n", sent_since_last_update, tx_sequence_number ); last_update = timeGetTime(); sent_since_last_update = 0; } //Sleep(1); } return 0;
}
USB trace
version 1.2.6
Please use the mailing list to post more details. Thanks. testlibusb-win.exe output should be helpful. DebugView debug log using the debug version of the driver should help as well.
Closing old entry. Please use libusb-win32 mailing list for future discussions.