PERFORCE change 166146 for review

Sylvestre Gallon syl at FreeBSD.org
Wed Jul 15 18:54:12 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=166146

Change 166146 by syl at syl_atuin on 2009/07/15 18:53:49

	Update testing for dumping extra_descriptors.

Affected files ...

.. //depot/projects/soc2009/syl_usb/libusb-tests/descriptors/test2/test2.c#5 edit
.. //depot/projects/soc2009/syl_usb/libusb-tests/descriptors/test3/test3.c#4 edit
.. //depot/projects/soc2009/syl_usb/libusb-tests/descriptors/test4/test4.c#3 edit
.. //depot/projects/soc2009/syl_usb/libusb-tests/descriptors/test5/test5.c#4 edit

Differences ...

==== //depot/projects/soc2009/syl_usb/libusb-tests/descriptors/test2/test2.c#5 (text+ko) ====

@@ -5,6 +5,24 @@
 	
 libusb_context *ctx;
 
+void
+dump_extra(char *str, uint8_t *extra, int extra_length)
+{
+	int i;
+
+	if (extra_length == 0)
+		return ;
+	printf("%sextra descriptor\n%s0x%.4x : ", str, str, 0);
+	for (i = 0 ; i < extra_length ; ) {
+		printf("0x%.2x ", extra[i]);
+		i++;
+		if (i != 0 && (i % 0x10) == 0) {
+			printf("\n%s0x%.4x : ", str, i);
+		}
+	}
+	printf("\n");
+}
+
 int
 main(int ac, const char *av[])
 {
@@ -48,7 +66,9 @@
 			printf("|---- bConfigurationValue : 0x%.2x\n", cdesc->bConfigurationValue);
 			printf("|---- iConfiguration : 0x%.2x\n", cdesc->iConfiguration);
 			printf("|---- bmAttributes : 0x%.2x\n", cdesc->bmAttributes);
-			printf("|---- MaxPower : 0x%.2x\n|\n", cdesc->MaxPower);
+			printf("|---- MaxPower : 0x%.2x\n", cdesc->MaxPower);
+			dump_extra("|---- ", cdesc->extra, cdesc->extra_length);
+			printf("|\n");
 			for (j = 0 ; j < cdesc->bNumInterfaces ; j++) {
 				for (k = 0 ; k < cdesc->interface[j].num_altsetting ; k++) {
 					idesc = &cdesc->interface[j].altsetting[k];
@@ -62,7 +82,9 @@
 					printf("|------ bInterfaceClass 0x%.2x\n", idesc->bInterfaceClass);
 					printf("|------ bInterfaceSubClass 0x%.2x\n", idesc->bInterfaceSubClass);
 					printf("|------ bInterfaceProtocol 0x%.2x\n", idesc->bInterfaceProtocol);
-					printf("|------ iInterface 0x%.2x\n|\n", idesc->iInterface);
+					printf("|------ iInterface 0x%.2x\n", idesc->iInterface);
+					dump_extra("|------ ", idesc->extra, idesc->extra_length);
+					printf("|\n");
 					for (l = 0 ; l < idesc->bNumEndpoints ; l++) {
 						edesc = &idesc->endpoint[l];
 						printf("|-------- DESCRIPTOR :\n");
@@ -73,7 +95,9 @@
 						printf("|-------- wMaxPacketSize 0x%.4x\n", edesc->wMaxPacketSize);
 						printf("|-------- bInterval 0x%.2x\n", edesc->bInterval);
 						printf("|-------- bRefresh 0x%.2x\n", edesc->bRefresh);
-						printf("|-------- bSynchAddress 0x%.2x\n|\n", edesc->bSynchAddress);
+						printf("|-------- bSynchAddress 0x%.2x\n", edesc->bSynchAddress);
+						dump_extra("|-------- ", edesc->extra, edesc->extra_length);
+						printf("|\n");
 					}
 				}
 			}

==== //depot/projects/soc2009/syl_usb/libusb-tests/descriptors/test3/test3.c#4 (text+ko) ====

@@ -5,6 +5,24 @@
 	
 libusb_context *ctx;
 
+void
+dump_extra(char *str, uint8_t *extra, int extra_length)
+{
+	int i;
+
+	if (extra_length == 0)
+		return ;
+	printf("%sextra descriptor\n%s0x%.4x : ", str, str, 0);
+	for (i = 0 ; i < extra_length ; ) {
+		printf("0x%.2x ", extra[i]);
+		i++;
+		if (i != 0 && (i % 0x10) == 0) {
+			printf("\n%s0x%.4x : ", str, i);
+		}
+	}
+	printf("\n");
+}
+
 int
 main(int ac, const char *av[])
 {
@@ -57,7 +75,9 @@
 				printf("|---- bConfigurationValue : 0x%.2x\n", cdesc->bConfigurationValue);
 				printf("|---- iConfiguration : 0x%.2x\n", cdesc->iConfiguration);
 				printf("|---- bmAttributes : 0x%.2x\n", cdesc->bmAttributes);
-				printf("|---- MaxPower : 0x%.2x\n|\n", cdesc->MaxPower);
+				printf("|---- MaxPower : 0x%.2x\n", cdesc->MaxPower);
+				dump_extra("|---- ", cdesc->extra, cdesc->extra_length);
+				printf("|\n");
 				for (j = 0 ; j < cdesc->bNumInterfaces ; j++) {
 					for (k = 0 ; k < cdesc->interface[j].num_altsetting ; k++) {
 						idesc = &cdesc->interface[j].altsetting[k];
@@ -71,7 +91,9 @@
 						printf("|------ bInterfaceClass 0x%.2x\n", idesc->bInterfaceClass);
 						printf("|------ bInterfaceSubClass 0x%.2x\n", idesc->bInterfaceSubClass);
 						printf("|------ bInterfaceProtocol 0x%.2x\n", idesc->bInterfaceProtocol);
-						printf("|------ iInterface 0x%.2x\n|\n", idesc->iInterface);
+						printf("|------ iInterface 0x%.2x\n", idesc->iInterface);
+						dump_extra("|------ ", idesc->extra, idesc->extra_length);
+						printf("|\n");
 						for (l = 0 ; l < idesc->bNumEndpoints ; l++) {
 							edesc = &idesc->endpoint[l];
 							printf("|-------- DESCRIPTOR :\n");
@@ -82,7 +104,9 @@
 							printf("|-------- wMaxPacketSize 0x%.4x\n", edesc->wMaxPacketSize);
 							printf("|-------- bInterval 0x%.2x\n", edesc->bInterval);
 							printf("|-------- bRefresh 0x%.2x\n", edesc->bRefresh);
-							printf("|-------- bSynchAddress 0x%.2x\n|\n", edesc->bSynchAddress);
+							printf("|-------- bSynchAddress 0x%.2x\n", edesc->bSynchAddress);
+							dump_extra("|-------- ", edesc->extra, edesc->extra_length);
+							printf("|\n");
 						}
 					}
 				}

==== //depot/projects/soc2009/syl_usb/libusb-tests/descriptors/test4/test4.c#3 (text+ko) ====

@@ -5,6 +5,24 @@
 	
 libusb_context *ctx;
 
+void
+dump_extra(char *str, uint8_t *extra, int extra_length)
+{
+	int i;
+
+	if (extra_length == 0)
+		return ;
+	printf("%sextra descriptor\n%s0x%.4x : ", str, str, 0);
+	for (i = 0 ; i < extra_length ; ) {
+		printf("0x%.2x ", extra[i]);
+		i++;
+		if (i != 0 && (i % 0x10) == 0) {
+			printf("\n%s0x%.4x : ", str, i);
+		}
+	}
+	printf("\n");
+}
+
 int
 main(int ac, const char *av[])
 {
@@ -48,7 +66,9 @@
 			printf("|---- bConfigurationValue : 0x%.2x\n", cdesc->bConfigurationValue);
 			printf("|---- iConfiguration : 0x%.2x\n", cdesc->iConfiguration);
 			printf("|---- bmAttributes : 0x%.2x\n", cdesc->bmAttributes);
-			printf("|---- MaxPower : 0x%.2x\n|\n", cdesc->MaxPower);
+			printf("|---- MaxPower : 0x%.2x\n", cdesc->MaxPower);
+			dump_extra("|---- ", cdesc->extra, cdesc->extra_length);
+			printf("|\n");
 			for (j = 0 ; j < cdesc->bNumInterfaces ; j++) {
 				for (k = 0 ; k < cdesc->interface[j].num_altsetting ; k++) {
 					idesc = &cdesc->interface[j].altsetting[k];
@@ -62,7 +82,9 @@
 					printf("|------ bInterfaceClass 0x%.2x\n", idesc->bInterfaceClass);
 					printf("|------ bInterfaceSubClass 0x%.2x\n", idesc->bInterfaceSubClass);
 					printf("|------ bInterfaceProtocol 0x%.2x\n", idesc->bInterfaceProtocol);
-					printf("|------ iInterface 0x%.2x\n|\n", idesc->iInterface);
+					printf("|------ iInterface 0x%.2x\n", idesc->iInterface);
+					dump_extra("|------ ", idesc->extra, idesc->extra_length);
+					printf("|\n");
 					for (l = 0 ; l < idesc->bNumEndpoints ; l++) {
 						edesc = &idesc->endpoint[l];
 						printf("|-------- DESCRIPTOR :\n");
@@ -73,7 +95,9 @@
 						printf("|-------- wMaxPacketSize 0x%.4x\n", edesc->wMaxPacketSize);
 						printf("|-------- bInterval 0x%.2x\n", edesc->bInterval);
 						printf("|-------- bRefresh 0x%.2x\n", edesc->bRefresh);
-						printf("|-------- bSynchAddress 0x%.2x\n|\n", edesc->bSynchAddress);
+						printf("|-------- bSynchAddress 0x%.2x\n", edesc->bSynchAddress);
+						dump_extra("|-------- ", edesc->extra, edesc->extra_length);
+						printf("|\n");
 					}
 				}
 			}

==== //depot/projects/soc2009/syl_usb/libusb-tests/descriptors/test5/test5.c#4 (text+ko) ====



More information about the p4-projects mailing list