On 7/22/10 12:29 PM, Wander Lairson wrote:
> I will try to install a darwin kernel in a VM and debug it...
>
When you say, "debug it" - do you mean libusb01 itself? I can
provide some info:
$ export USB_DEBUG=10
$ ./usbtest
usb_set_debug: Setting debugging level to 10 (on)
usb_os_find_busses: Found 001
usb_os_find_busses: Found 002
usb_os_find_busses: Found 003
usb_os_find_busses: Found 004
usb_os_find_busses: Found 005
usb_os_find_devices: Found USB device at location 0x1d000000
usb_os_find_devices: Found 001-05ac-8005-09-00 on 001 at location 0x1d000000
usb_os_find_devices: Found USB device at location 0x1d200000
usb_os_find_devices: Found 002-05ac-021a-00-00 on 001 at location 0x1d200000
usb_os_find_devices: Found USB device at location 0x3d000000
usb_os_find_devices: Found USB device at location 0x5d000000
usb_os_find_devices: Found USB device at location 0x5d200000
usb_os_find_devices: Found USB device at location 0x7d000000
usb_os_find_devices: Found USB device at location 0x7d100000
usb_os_find_devices: Found USB device at location 0xfd000000
usb_os_find_devices: Found USB device at location 0xfd400000
usb_os_open: 05ac:021a
usb_control_msg: 128 6 512 0 0xbffff7c8 8 1000
usb_control_msg: 128 6 512 0 0x102ea0 84 1000
skipped 1 class/vendor specific interface descriptors
skipped 1 class/vendor specific interface descriptors
skipped 1 class/vendor specific interface descriptors
usb_os_close: 05ac:021a
usb_os_open: 05ac:8005
usb_os_open(USBDeviceOpenSeize): another process has device opened for
exclusive access
usb_control_msg: 128 6 512 0 0xbffff7c8 8 1000
usb_control_msg: 128 6 512 0 0x103ce0 27 1000
usb_os_close: 05ac:8005
usb_os_find_devices: Found USB device at location 0x1d000000
usb_os_find_devices: Found USB device at location 0x1d200000
usb_os_find_devices: Found USB device at location 0x3d000000
usb_os_find_devices: Found 001-05ac-8005-09-00 on 002 at location 0x3d000000
usb_os_find_devices: Found USB device at location 0x5d000000
usb_os_find_devices: Found USB device at location 0x5d200000
usb_os_find_devices: Found USB device at location 0x7d000000
usb_os_find_devices: Found USB device at location 0x7d100000
usb_os_find_devices: Found USB device at location 0xfd000000
usb_os_find_devices: Found USB device at location 0xfd400000
usb_os_open: 05ac:8005
usb_os_open(USBDeviceOpenSeize): another process has device opened for
exclusive access
usb_control_msg: 128 6 512 0 0xbffff7c8 8 1000
usb_control_msg: 128 6 512 0 0x102f50 27 1000
usb_os_close: 05ac:8005
#include <stdio.h>
#include <usb.h>
#include <string.h>
#include <errno.h>
#include "usbclassnames.h"
void
print_dev(struct usb_device *dev) {
}
void
print_bus(struct usb_bus *bus) {
int r;
int status;
int strIndex;
char str[1024];
memset(str, 0, sizeof(str));
errno = 0;
usb_dev_handle *h = usb_open(bus->devices);
if (errno != 0) perror("usb_open:");
status = usb_claim_interface(h, 1);//h->interface);
errno = status;
if (errno != 0) perror("usb_open:");
struct usb_device *dev = bus->devices;
struct usb_device_descriptor *devdescr = &dev->descriptor;
strIndex = 1; //devdescr->iManufacturer;
r = usb_get_string_simple(h, strIndex, str, sizeof(str));
usb_release_interface(h, 1);
printf("USB Bus: Bus Number: %02.02x: position: %s Index: %d res: %d %s\n",
bus->location>>24, bus->dirname, strIndex, r, str);
usb_close(h);
}
int
main(int argc, char *argv[]) {
struct usb_bus *busses;
usb_init();
usb_find_busses();
usb_find_devices();
busses = usb_get_busses();
//usb_set_debug(10);
struct usb_bus *bus;
int c, i, a;
for (bus = busses; bus; bus = bus->next) {
struct usb_device *dev;
//printf("BUS: %02.02x: %s ", bus->location>>24, bus->dirname);
print_bus(bus);
#if 0
for (dev = bus->devices; dev; dev = dev->next) {
if (dev->descriptor.bDeviceClass == 9) {
printf("Hub: %s - %d 0x%04.04x.0x%04.04x\n",
dev->filename,
dev->descriptor.bDeviceClass,
dev->descriptor.idVendor,
dev->descriptor.idProduct);
} else {
printf("\n\tDEV: %s - %d 0x%04.04x.0x%04.04x\n",
usb_get_classcode_base_name(
dev->descriptor.bDeviceClass),
dev->descriptor.bDeviceClass,
dev->descriptor.idVendor,
dev->descriptor.idProduct);
}
if (dev->descriptor.bDeviceClass == 7) {
/* Open the device, claim the interface and do your
processing */
}
/* Loop through all of the configurations */
for (c = 0; c < dev->descriptor.bNumConfigurations; c++) {
if (dev->config != (struct usb_config_descriptor*)0)
printf("\t\tConfig: %X - %X extra len: %d\n",
dev->config[c].bDescriptorType,
dev->config[c].bConfigurationValue,
dev->config[c].extralen);
/* Loop through all of the interfaces */
for (i = 0; dev->config && i <
dev->config[c].bNumInterfaces; i++) {
/* Loop through all of the alternate settings */
for (a = 0; a <
dev->config[c].interface[i].num_altsetting; a++) {
printf("\t\t\tAlt Interface: %d - %d Extra len:
%d\n",
dev->config[c].interface[i].altsetting[a].bInterfaceClass,
dev->config[c].interface[i].altsetting[a].bInterfaceNumber,
dev->config[c].interface[i].altsetting[a].extralen);
/* Check if this interface is a printer */
if
(dev->config[c].interface[i].altsetting[a].bInterfaceClass == 7) {
/* Open the device, set the alternate setting,
claim the interface and do your processing */
}
}
}
}
}
#endif
}
}
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users