General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
-
jayantdhawan
- Posts: 2
- Joined: Wed May 21, 2008 9:49 pm
- Location: New Delhi, India
-
Contact:
Post
by jayantdhawan » Wed May 21, 2008 10:25 pm
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
-
christian
- Objective Development
- Posts: 1443
- Joined: Thu Nov 09, 2006 11:46 am
Post
by christian » Wed May 28, 2008 5:22 pm
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).
-
Pit Bull
- Posts: 2
- Joined: Wed Jul 09, 2008 12:24 pm
Post
by Pit Bull » Wed Jul 09, 2008 12:29 pm
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.
-
christian
- Objective Development
- Posts: 1443
- Joined: Thu Nov 09, 2006 11:46 am
Post
by christian » Wed Jul 09, 2008 12:55 pm
Do this after opening the device in your host side software's main.
-
Pit Bull
- Posts: 2
- Joined: Wed Jul 09, 2008 12:24 pm
Post
by Pit Bull » Wed Jul 09, 2008 4:05 pm
Thank's!
You realy help me.
Objective Development rulzz.
-
jayantdhawan
- Posts: 2
- Joined: Wed May 21, 2008 9:49 pm
- Location: New Delhi, India
-
Contact:
Post
by jayantdhawan » Sat Jul 12, 2008 4:33 pm
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
-
pirxdeij
Post
by pirxdeij » Sun Jul 13, 2008 12:27 am
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.
-
christian
- Objective Development
- Posts: 1443
- Joined: Thu Nov 09, 2006 11:46 am
Post
by christian » Mon Jul 14, 2008 12:38 pm
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!
-
epsilon_da
- Rank 1
- Posts: 29
- Joined: Mon Oct 13, 2008 7:11 pm
Post
by epsilon_da » Sat Oct 18, 2008 5:38 pm
Same problem here with Linux Debian and both solutions worked.
I think that it should be fixed in the lasts usbdrv tarbals.