|
From: Michael K. <Mic...@SO...> - 2002-05-24 13:15:21
|
Hello,
i would like to write a userspace driver for a unsupported USB device.
I've got some information from the manufactor how to acces the device.
At the moment i make my first steps with libusb 0.1.5.
Based on the testlibusb.c i try to make a control transfer to the default
Endpoint 0. I can open the device, but when i send the control message,
i got errorcode -1. I enabled the debug output and libusb says the
following:
USB error: error sending control message: No such file or directory
Program was started as root. Has anybody an idea what type of file or
directory
is needed? /proc/bus/usb/... is mounted and i can see the files in it.
Below you can find the modified sourcecode and the program output.
With the control message i would like to read 8 Bytes from the USB device
with
a Vendor RequestType from Endpoint 0.
Thank you very much for your help in advance!
Michael
------------------------------ C-Sourcecode -------------------------------
main (void)
{
struct usb_bus *bus;
struct usb_device *dev;
struct usb_dev_handle *dev_handle;
int x, c;
unsigned char buffer[5000];
for (x = 0; x < 5000; x++)
buffer[x] = 0xAA;
usb_set_debug (2);
usb_init ();
usb_find_busses ();
usb_find_devices ();
printf ("bus/device idVendor/idProduct\n");
for (bus = usb_busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
int i;
printf ("%s/%s %04X/%04X\n", bus->dirname, dev->filename,
dev->descriptor.idVendor, dev->descriptor.idProduct);
if ((dev->descriptor.idVendor ==
0x0e50) & (dev->descriptor.idProduct == 0x0001))
{
printf ("** Device Found **\n");
dev_handle = usb_open (dev);
if (!dev_handle)
printf ("Open failed!\n");
else
printf ("Open Successful!\n ");
if (usb_set_configuration (dev_handle, 1) == 0)
printf ("Set the config\n");
else
printf ("Error setting configuration\n");
c=usb_control_msg (dev_handle,
USB_ENDPOINT_IN | USB_TYPE_VENDOR |
USB_RECIP_ENDPOINT, 'O', 0x0000, 0x0000,
buffer, 8, 5000);
printf ("control_msg returncode=%d\n", c);
for (x = 0; x < 8; x++)
printf ("%2X ", buffer[x]);
printf ("\n");
}
if (!dev->config)
{
printf (" Couldn't retrieve descriptors\n");
continue;
}
for (i = 0; i < dev->descriptor.bNumConfigurations; i++)
print_configuration (&dev->config[i]);
}
}
return 0;
}
------------------------------ Program Output
-------------------------------
usb_set_debug: Setting debugging level to 2 (on)
usb_os_init: Found USB VFS at /proc/bus/usb
usb_find_busses: Skipping non bus directory devices
usb_find_busses: Skipping non bus directory drivers
usb_find_busses: Found 001
usb_find_devices_on_bus: Found 001 on 001
usb_find_devices_on_bus: Found 030 on 001
bus/device idVendor/idProduct
001/030 0E50/0001
** Device Found **
Open Successful!
Set the config
USB error: error sending control message: No such file or directory
control_msg returncode=-1
AA AA AA AA AA AA AA AA
wTotalLength: 18
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 4
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 0
bInterfaceClass: 0
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
001/001 0000/0000
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 40h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 8
bInterval: 255
bRefresh: 0
bSynchAddress: 0
|