I tried to implement Bulk transfer from the Launchpad to a PC. There is precious little information on this. I did the following:
In the PC, I use libusb 1.0, and this (extract from the) code:
printf("Reading data...\n"); for (block = 0; block < 50; block++) { r = libusb_bulk_transfer(dev_handle, EP_IN, data, 512, &actual, 1000); if (r == 0) { printf("%d bytes received (%04x)\n", actual, data[0]); if (actual > 0) { // show_received_bytes(data, actual); } } else printf("Read error (%d): %s\n", r, libusb_error_name(r)); }
In the Launchpad I did the following:
USBStackModeSet(0, USB_MODE_FORCE_DEVICE, 0); USBDBulkInit(0, (tUSBDBulkDevice *)&g_sBulkDevice); usb_ep_loaded = 0; while(1) { // The data is actually acquierd from the AD converters. I've removed that code for size. USBEndpointDataPut(USB0_BASE, USB_EP_1, (unsigned char *)ADC0_data, sizeof(ADC0_data)); USBEndpointDataPut(USB0_BASE, USB_EP_1, (unsigned char *)ADC1_data, sizeof(ADC1_data)); usb_ep_loaded += sizeof(ADC0_data) * 2; if (usb_ep_loaded == BULK_BUFFER_SIZE) { USBEndpointDataSend(USB0_BASE, USB_EP_1, USB_TRANS_IN); usb_ep_loaded = 0; // blink_LED(1, 20); // Was 100 } }
On the first run, the transfer starts, transfering a couple of times. Then an incomplete package comes in, and I get a LIBUSB_ERROR_PIPE. Subsequent tries immediately give that error - no data.
Wireshark seems to dislike this error, and hangs.
Using the usbmon framework, I get this:
ffff8802108e4300 4001048649 S Bi:1:016:1 -115 512 <
ffff8802108e4300 4001050832 C Bi:1:016:1 0 512 = 010000e2 000000e7 000000f6 00000000 010000f7 00000004 010000f6 00000006
ffff8802108e4300 4001050943 S Bi:1:016:1 -115 512 <
ffff8802108e4300 4001051762 C Bi:1:016:1 0 192 = fa000000 03010000 f7000000 03010000 f9000000 03010000 f7000000 07010000
ffff8802108e4300 4001051875 S Bi:1:016:1 -115 512 <
ffff8802108e4300 4001052133 C Bi:1:016:1 -32 0
ffff8802108e4300 4001052163 S Bi:1:016:1 -115 512 <
ffff8802108e4300 4001061081 C Bi:1:016:1 -71 0
ffff880214b82d80 4001061091 S Co:1:006:0 s 23 08 9101 0001 0000 0
ffff8802108e4300 4001061127 S Bi:1:016:1 -115 512 <
ffff880214b82d80 4001061382 C Co:1:006:0 0 0
ffff8802108e4300 4001071645 C Bi:1:016:1 -71 0
ffff8801c3e30000 4001071663 S Co:1:006:0 s 23 08 9101 0001 0000 0
ffff8802108e4300 4001071781 S Bi:1:016:1 -115 512 <
ffff8801c3e30000 4001072001 C Co:1:006:0 0 0
ffff8802108e4300 4001082008 C Bi:1:016:1 -71 0
ffff880207f00a80 4001082025 S Co:1:006:0 s 23 08 9101 0001 0000 0
ffff8802108e4300 4001082124 S Bi:1:016:1 -115 512 <
The first transfers are a 512 complete packet, and a 192 incomplete packet (with the LIBUSB_ERROR_PIPE). Strangely, there seem to be several more 512-byte packets announced here, but the error stops those from being processed.
Any suggestion what could cause this? I suspect over-run - data not being processed in time.