From 13b60901d894ed21d4fe51ba31b06c8f70413839 Mon Sep 17 00:00:00 2001 From: laforge Date: Wed, 4 Oct 2006 21:16:34 +0000 Subject: - add support to read the serial number - add support for new OpenPCD firmware revisions with multiple interfaces git-svn-id: https://svn.openpcd.org:2342/trunk@263 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- host/opcd_usb.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'host/opcd_usb.c') diff --git a/host/opcd_usb.c b/host/opcd_usb.c index 9224516..d5f7db9 100644 --- a/host/opcd_usb.c +++ b/host/opcd_usb.c @@ -54,20 +54,21 @@ opcd_hexdump(const void *data, unsigned int len) #define OPCD_IN_EP 0x82 #define OPCD_INT_EP 0x83 -static struct usb_device *find_opcd_handle(void) +static struct usb_device *find_opcd_handle(int picc) { struct usb_bus *bus; + u_int16_t product_id; + + if (picc) + product_id = OPENPICC_PRODUCT_ID; + else + product_id = OPENPCD_PRODUCT_ID; for (bus = usb_busses; bus; bus = bus->next) { struct usb_device *dev; for (dev = bus->devices; dev; dev = dev->next) { - if (dev->descriptor.idVendor == OPENPCD_VENDOR_ID - && (dev->descriptor.idProduct == OPENPCD_PRODUCT_ID || - dev->descriptor.idProduct == OPENPCD_PRODUCT_ID) - && dev->descriptor.iManufacturer == 0 - && dev->descriptor.iProduct == 0 - && dev->descriptor.bNumConfigurations == 1 - && dev->config->iConfiguration == 0) + if (dev->descriptor.idVendor == OPENPCD_VENDOR_ID && + dev->descriptor.idProduct == product_id) return dev; } } @@ -100,7 +101,7 @@ static void handle_interrupt(struct usbdevfs_urb *uurb, void *userdata) fprintf(stderr, "unable to resubmit interupt urb\n"); } -struct opcd_handle *opcd_init(void) +struct opcd_handle *opcd_init(int picc) { struct opcd_handle *oh; struct usb_device *dev; @@ -113,7 +114,7 @@ struct opcd_handle *opcd_init(void) ausb_init(); - dev = find_opcd_handle(); + dev = find_opcd_handle(picc); if (!dev) { fprintf(stderr, "Cannot find OpenPCD device. " "Are you sure it is connected?\n"); @@ -163,8 +164,9 @@ int opcd_recv_reply(struct opcd_handle *od, char *buf, int len) return ret; } - printf("RX: %s\n", opcd_hexdump(buf, ret)); - opcd_dump_hdr((struct openpcd_hdr *)buf); + //printf("RX: %s\n", opcd_hexdump(buf, ret)); + //printf("RX: %s\n", opcd_hexdump(buf, 48)); + //opcd_dump_hdr((struct openpcd_hdr *)buf); return ret; } -- cgit v1.2.3