I have a problem with a USB project using LIB-USB . The USB device is based on the PIC18F4550 and has a single control endpoint. The PC interface is written in MSVC and uses Lib-Usb 1.12.
At the end of the PC, the program starts by setting the configuration, submitting a request to the interface, and then sending (and receiving) control messages (vendor-specific), all successfully. After a random number of bytes has been transferred (somewhere between 100 and 2000), the transfer stops with the rc = -5 error returned from the usb_control_msg call.
At the PC end, the calls are as follows:
ret = usb_set_configuration(udev, 1); ret = usb_claim_interface(udev, 0); ret = usb_control_msg(udev, USB_TYPE_VENDOR|USB_RECIP_DEVICE, CMD_RESET, 0, 0, buffer, 0, 100); ret = usb_control_msg(udev, 0xC0, GET_FIFO_DATA, 0, 0, buffer, 8, 100);
The last call, which actually receives data from the USB device, is made many times in a row, but always dies after a random number of bytes (from 100 to 2000 in total). Changing the pipe to EP1 does the same with the same error that ultimately appears.
On a USB device (PIC), the end of the descriptor is very simple, it has only the EP0 channel and looks like this:
Device db 0x12, DEVICE ; bLength, bDescriptorType db 0x10, 0x01 ; bcdUSB (low byte), bcdUSB (high byte) db 0x00, 0x00 ; bDeviceClass, bDeviceSubClass db 0x00, MAX_PACKET_SIZE ; bDeviceProtocol, bMaxPacketSize db 0xD8, 0x04 ; idVendor (low byte), idVendor (high byte) db 0x01, 0x00 ; idProduct (low byte), idProduct (high byte) db 0x00, 0x00 ; bcdDevice (low byte), bcdDevice (high byte) db 0x01, 0x02 ; iManufacturer, iProduct db 0x00, NUM_CONFIGURATIONS ; iSerialNumber (none), bNumConfigurations Configuration1 db 0x09, CONFIGURATION ; bLength, bDescriptorType db 0x12, 0x00 ; wTotalLength (low byte), wTotalLength (high byte) db NUM_INTERFACES, 0x01 ; bNumInterfaces, bConfigurationValue db 0x00, 0xA0 ; iConfiguration (none), bmAttributes db 0x32, 0x09 ; bMaxPower (100 mA), bLength (Interface1 descriptor starts here) db INTERFACE, 0x00 ; bDescriptorType, bInterfaceNumber db 0x00, 0x00 ; bAlternateSetting, bNumEndpoints (excluding EP0) db 0xFF, 0x00 ; bInterfaceClass (vendor specific class code), bInterfaceSubClass db 0xFF, 0x00 ; bInterfaceProtocol (vendor specific protocol used), iInterface (none)
The actual structure is Bradley Mintch in assembly language.
If someone has encountered this type of problem before I want to hear about it, since I tried everything to solve the problem, including using a different channel (EP1 with the same results), check the UOWN bit on the PIC before recording to the pipe, setting communication with the host PC (where the PC must send a vendor-specific command before recording the dates), but to no avail.