I'm having an issue with a USB project using LIB-USB. The USB device is based on a PIC18F4550 and has a single control endpoint. The PC front-end is written in MSVC and uses Lib-Usb 1.12.
On the PC end, the program begins by setting the configuration, claiming the interface, then sending (and receiving) control messages (vendor specific), all successfully. After what seems like a random # of bytes have been transferred (anywhere between 100 and 2000) the transfer halts with an error rc=-5 returned from the usb_control_msg call.
On the PC-end, the calls look like this:
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 acquires data from the USB device, runs many times in sucession but always dies after a random number of bytes (100 to 2000 in total) are transferred in this way. Changing the pipe to EP1 does the same thing with the same error eventually appearing.
On the USB device (PIC) end the descriptor is very simple, having only the EP0 pipe, 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 framework is that of Bradley Minch's in assembly language.
If anyone has encountered this type of problem before I'd love to hear about it as I've tried just about everything to solve it including using a different pipe (EP1, with the same results), checking the UOWN bit on the PIC before writing to the pipe, handshaking with the PC host (where the PC must send a vendor-specific command first before the datsa is written) but to no avail.
Thanks! Mark