Page 1 of 1
AVR USB command-line error
Posted: Wed May 21, 2008 10:25 pm
by jayantdhawan
Hi,
I'm using an ATmega8 to run the firmware for AVR USB (version avrusb-20080418). The device is being detected by the host but when the command-line tool, running on Slackware 12, is used to write a byte to the device, it returns the following error:
Code: Select all
Error sending message: error sending control message: Device or resource busy
error writing data: Communication error with device
The 'dmesg' output gives the following entry related to the process:
Code: Select all
usb 2-1: usbfs: process 14201 (hidtool) did not claim interface 0 before use
Running it on another system (Ubuntu) gives the following error:
Code: Select all
Warning: cannot query manufacturer for device: error sending control message: Operation not permitted
error finding DataStore: Communication error with device
Could anyone please provide the solution?
Regards
Jayant
Posted: Wed May 28, 2008 5:22 pm
by christian
The first error indicates that Linux insists that you claim an interface. That's somewhat strange, since it should be possible to query the device's string descriptors (through endpoint 0) when the device is otherwise busy. But you can change the code accordingly:
Code: Select all
int retries = 1, usbConfiguration = 1, usbInterface = 0;
if(usb_set_configuration(handle, usbConfiguration) && showWarnings){
fprintf(stderr, "Warning: could not set configuration: %s\n", usb_strerror());
}
/* now try to claim the interface and detach the kernel HID driver on
* linux and other operating systems which support the call.
*/
while((len = usb_claim_interface(handle, usbInterface)) != 0 && retries-- > 0){
#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
if(usb_detach_kernel_driver_np(handle, 0) < 0 && showWarnings){
fprintf(stderr, "Warning: could not detach kernel driver: %s\n", usb_strerror());
}
#endif
}
The second error tells you that you don't have permissions to the USB device. This is a hotplug configuration issue. Try it as root, that should work (or give the same error as above).
slackware error
Posted: Wed Jul 09, 2008 12:29 pm
by Pit Bull
Hi jayantdhawan
You find fix of that problem?
I'm use Slackware 10.1 and hid-data example.
In Windows XP it work's normaly, but in Slackware i get error:
Error sending message: error sending control message: Device or resource busy
error writing data: Communication error with device
I'm do not understand where i should write this code?
int retries = 1, usbConfiguration = 1, usbInterface = 0;
if(usb_set_configuration(handle, usbConfiguration) && showWarnings){
fprintf(stderr, "Warning: could not set configuration: %s\n", usb_strerror());
}
/* now try to claim the interface and detach the kernel HID driver on
* linux and other operating systems which support the call.
*/
while((len = usb_claim_interface(handle, usbInterface)) != 0 && retries-- > 0){
#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
if(usb_detach_kernel_driver_np(handle, 0) < 0 && showWarnings){
fprintf(stderr, "Warning: could not detach kernel driver: %s\n", usb_strerror());
}
#endif
}
which file ? in hidtool.c ?
Please help.
Posted: Wed Jul 09, 2008 12:55 pm
by christian
Do this after opening the device in your host side software's main.
Posted: Wed Jul 09, 2008 4:05 pm
by Pit Bull
Thank's!
You realy help me.
Objective Development rulzz.
Posted: Sat Jul 12, 2008 4:33 pm
by jayantdhawan
Hi Pit Bull,
Excuse me for the late reply. I was able to fix the problem with the code given by Christian. It seems you were able to do that as well.
Regards
Jayant
Solved similar problem in example hidtool
Posted: Sun Jul 13, 2008 12:27 am
by pirxdeij
I'm evaluating AVR-USB on Kubuntu Hardy Heron and also got the same message in dmesg:
"did not claim interface 0 before use"
I have solved the problem by replacing both occurrences in hiddata.c of USB_RECIP_INTERFACE by USB_RECIP_DEVICE.
Hope this helps other people.
Posted: Mon Jul 14, 2008 12:38 pm
by christian
Thanks a lot for this suggestion! Seems logical and should solve the problem in a much more elegant way!
I'll include this in the next release!
Posted: Sat Oct 18, 2008 5:38 pm
by epsilon_da
Same problem here with Linux Debian and both solutions worked.
I think that it should be fixed in the lasts usbdrv tarbals.