SetAltInterface() error 31

Johny Gudlik <[email protected]>
Newsgroups gmane.comp.lib.libusb.devel.windows
Message-ID <CADKz-bUVesP-609eUAg1Gn25QngwbGXQHbH_iMgoKMZsoM-spw@mail.gmail.com>
Hello,
I have problem with USB on SAM3S2C (user board) configured as USB device
Vendor Class (it is my first project with USB). I can't set alternate
setting to 1 of the interface 0. Device is opened successfully, but I get
error in function  SetAltInterface() - 31 (0x1F)  (ERROR_GEN_FAILURE  A
device attached to the system is not functioning).

I'm using libusbK 3.0.7.0., Windows 7.
USB: 2.0, Full speed

What am I doing wrong?

Thank you,
Milan

DWORD __cdecl main(int argc, char* argv[])
{
...
Examples_GetTestDevice(...);
LibK_LoadDriverAPI(...);
Usb.Init(...);
ConfigureDevice(...); // Fail
...
}

BOOL ConfigureDevice(KUSB_HANDLE UsbHandle, PKUSB_DRIVER_API DriverAPI)
{
DWORD errorCode = ERROR_SUCCESS;

if (!DriverAPI->SetConfiguration(UsbHandle, 1))
{
errorCode = GetLastError();
printf("UsbK_SelectInterface failed. ErrorCode: %d, %08Xh\n", errorCode,
errorCode);
return FALSE;
}

if (!DriverAPI->ClaimInterface(UsbHandle, 0, FALSE))
{
errorCode = GetLastError();
printf("UsbK_ClaimInterface failed. ErrorCode: %d, %08Xh\n", errorCode,
errorCode);
return FALSE;
}

 if (!DriverAPI->SetAltInterface(UsbHandle, 0, FALSE, 1)) // Get error 31
{
errorCode = GetLastError();
printf("UsbK_SetCurrentAlternateSetting failed. ErrorCode: %d, %08Xh\n",
errorCode, errorCode);
return FALSE;
}
return TRUE;
}

Device configurations (from enum_descriptors example for libusbK):

[Config Descriptor]
bLength :9
bDescriptorType :0x02
wTotalLength :55
bNumInterfaces :1
bConfigurationValue :1
iConfiguration :0
bmAttributes :0x80
MaxPower :250

[Interface Descriptor]
bLength :9
bDescriptorType :0x04
bInterfaceNumber :0
bAlternateSetting :0
bNumEndpoints :0
bInterfaceClass :0xFF
bInterfaceSubClass :0xFF
bInterfaceProtocol :0xFF
iInterface :0

[Interface Descriptor]
bLength :9
bDescriptorType :0x04
bInterfaceNumber :0
bAlternateSetting :1
bNumEndpoints :4
bInterfaceClass :0xFF
bInterfaceSubClass :0xFF
bInterfaceProtocol :0xFF
iInterface :0

[Endpoint Descriptor]
bLength :7
bDescriptorType :0x05
bEndpointAddress :0x83
bmAttributes :0x03
wMaxPacketSize :64
bInterval :1

[Endpoint Descriptor]
bLength :7
bDescriptorType :0x05
bEndpointAddress :0x06
bmAttributes :0x03
wMaxPacketSize :64
bInterval :1

[Endpoint Descriptor]
bLength :7
bDescriptorType :0x05
bEndpointAddress :0x81
bmAttributes :0x02
wMaxPacketSize :64
bInterval :0

[Endpoint Descriptor]
bLength :7
bDescriptorType :0x05
bEndpointAddress :0x02
bmAttributes :0x02
wMaxPacketSize :64
  bInterval :0

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs

_______________________________________________
Libusb-win32-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.