Date: Sun, 31 May 2009 13:03:01 GMT From: Sylvestre Gallon <syl@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 163163 for review Message-ID: <200905311303.n4VD31vm074278@repoman.freebsd.org>
index | next in thread | raw e-mail
http://perforce.freebsd.org/chv.cgi?CH=163163 Change 163163 by syl@syl_rincewind on 2009/05/31 13:02:06 Finish to implement test5 who dump Manufacturer, Product and SerialNumber strings descriptors. Affected files ... .. //depot/projects/soc2009/syl_usb/libusb-tests/descriptors/test5/test5.c#3 edit .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#24 edit Differences ... ==== //depot/projects/soc2009/syl_usb/libusb-tests/descriptors/test5/test5.c#3 (text+ko) ==== @@ -9,6 +9,7 @@ main(int ac, const char *av[]) { libusb_device_handle *devh; + libusb_device_descriptor *ddesc; libusb_device **devs_list; char buff[512]; int ret; @@ -18,6 +19,12 @@ printf("This program will print out all the device" " strings descriptors for all the present devices.\n"); + ddesc = malloc(sizeof(libusb_device_descriptor)); + if (ddesc == NULL) { + perror("test5"); + return (EXIT_FAILURE); + } + if (libusb_init(&ctx) != 0) { fprintf(stderr, "libusb_init failed\n"); return (EXIT_FAILURE); @@ -43,12 +50,25 @@ return (EXIT_SUCCESS); } - ret2 = libusb_get_string_descriptor_ascii(devh, 0, buff, 512); - if (ret2 > 0) { - fprintf(stderr, "libusb open error.\n"); - return (EXIT_SUCCESS); + libusb_get_device_descriptor(devs_list[i], ddesc); + + if (ddesc->iManufacturer == 0) { + printf("\tNo Manufacturer string\n"); + } else { + libusb_get_string_descriptor_ascii(devh, ddesc->iManufacturer, buff, 512); + printf("\tManufacturer : %s\n", buff); + } + if (ddesc->iProduct == 0) { + printf("\tNo Product string\n"); + } else { + libusb_get_string_descriptor_ascii(devh, ddesc->iProduct, buff, 512); + printf("\tProduct : %s\n", buff); + } + if (ddesc->iSerialNumber == 0) { + printf("\tNo Serial Number string\n"); } else { - printf("string desc size : %i\n", ret2); + libusb_get_string_descriptor_ascii(devh, ddesc->iSerialNumber, buff, 512); + printf("\tSerialNumber : %s\n", buff); } } return (EXIT_SUCCESS); ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#24 (text+ko) ==== @@ -679,7 +679,7 @@ { pthread_mutex_lock(&libusb20_lock); - switch (libusb20_tr_get_status(usb20_xfer)) { + switch (libusb20_tr_get_status(xfer)) { case LIBUSB20_TRANSFER_COMPLETED: xfer->status = LIBUSB_TRANSFER_COMPLETED; break ;help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905311303.n4VD31vm074278>
