[C++] USB gadget driver, unbound kernel driver?
Hello Folks,
I try to write my own usb driver for my usb gadget, I write it on linux ubuntu with the libusb library. at this point i am able to setup a connection to the device but when i try to set a actice configuration it gives me a error:
Device or resource busy.
so i looked at google and found the following topic:
topic
at the end of all the replies, the topic starter said that the problem was a kernel driver that was automatically attached tot the device and he had to unbound it with the following command:
my question is:
1. does somebody knows libusb and knows what the problem could be?
2. can somebody confirm that kernel drivers could be the problem, and needed to be unbound ?
3. does somebody know the command of "rsmod hid" for a ubuntu system because this command doesn't work for me.
Thanks in advanced,
Jelte.
Code:
/*
* main.cpp
*
* Created on: 30 dec 2009
* Author: jelte
*
* USB Missle launcher info:
* id-product: 514 - 0x1130
* id-vendor: 4400 - 0x0202
*/
#include <usb.h>
#include <iostream>
usb_dev_handle *locate_misslelauncher(void);
using namespace std;
int main()
{
struct usb_dev_handle *misslelauncher_handle;
usb_init();
usb_set_debug(2);
if((misslelauncher_handle = locate_misslelauncher()) == 0)
{
cout << "cannot open device!" << endl;
}
else
{
cout << "device open!" << endl;
int configstatus = 0;
configstatus = usb_set_configuration(misslelauncher_handle,5);
if(configstatus == 0)
{
cout << "set config succeeded!" << endl;
}
else
{
cout << "set config failed" << endl;
}
}
usb_close(misslelauncher_handle);
return 0;
}
usb_dev_handle *locate_misslelauncher(void)
{
unsigned int vendorid = 4400;
unsigned int productid = 514;
unsigned int located = 0;
struct usb_bus *bus;
struct usb_device *device;
usb_dev_handle *devicehandle = 0;
usb_find_busses();
usb_find_devices();
for(bus = usb_busses;bus;bus = bus->next)
{
for(device = bus->devices;device; device = device->next)
{
if(device->descriptor.idVendor == vendorid && device->descriptor.idProduct == productid)
{
located++;
devicehandle = usb_open(device);
}
}
}
if(devicehandle == 0)
{
return (0);
}
else
{
return (devicehandle);
}
}