i`m writting a simple application using libusb-win32 and AVRUSB on atmega8 and windows 7 (but I had also these problems on XP). I have installed LIBUSB64Fix. I have problem with endpoints other than endpoint 0. Control messages work fine. But when I want to send something by usb_bulk_write() to e.g. endpoint 1 I have some problems. I suppose that by the device side everything is ok, endpoints are "enabled" in usbconfig.h and when I run usblib test application (testlibusb-win.exe) I get:
Code: Select all
DLL version: 0.1.12.1
Driver version: 0.1.10.2
bus/device idVendor/idProduct
bus-0/\\.\libusb0-0001--0x16ad-0x05dc 16AD/05DC
- Manufacturer : obdev.at
- Product : Akcelerometr_XYZ
wTotalLength: 32
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 0
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 8
bInterval: 10
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 83h
bmAttributes: 03h
wMaxPacketSize: 8
bInterval: 10
bRefresh: 0
bSynchAddress: 0
So I can see that I should have two endpoints more than control ep.
My code of host application:
Code: Select all
int main()
{
usb_dev_handle* hDevice;
char buffer[8];
// OpenUsbDevice() - function finding devices and returning hadnle to ones - works fine
if( (hDevice = OpenUsbDevice()) == 0 ) {
cout << "Urzadzenie nieodnalezione" << endl;
exit(1);
}
int ctrl = usb_control_msg(hDevice, USB_TYPE_VENDOR, 1, 0, 0, 0, 0, 3000); // WORKS FINE
if(ctrl < 0 ){
cout << "Blad polaczenia" << endl;
exit(1);
}
usb_set_configuration(hDevice, 1);
usb_claim_interface(hDevice, 0);
cout << usb_strerror() << endl;
usb_bulk_write(hDevice, USB_ENDPOINT_IN | 1, buffer, sizeof(buffer), 5000);
cout << usb_strerror() << endl;
usb_release_interface(hDevice, 0);
usb_close(hDevice);
system("PAUSE");
return 0;
}
I`m getting such errors:
for claim function usb_claim_interface(hDevice, 0); (when second parameter is 0) :
usb_os_find_devices: couldn't read device descriptor
for claim function usb_claim_interface(hDevice, 1); (when second parameter is 1) :
usb_claim_interface: could not claim interface 1, win error: The parameter is in correct.
for usb_bulk_write(hDevice, USB_ENDPOINT_IN | 1, buffer, sizeof(buffer), 5000); i got:
_usb_setup_async: invalid endpoint 0x81
Please, help...