Przeglądaj źródła

fixed a bug: according to HID 1.11 specification, wDescriptorLength field has the size of 2 bytes

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@8655 8c9fc860-2736-0410-a75d-ab315db34111
eth.morozova 6 lat temu
rodzic
commit
a3f0ca3b51
1 zmienionych plików z 5 dodań i 5 usunięć
  1. 5 5
      source/UsbHid.Mod

+ 5 - 5
source/UsbHid.Mod

@@ -199,7 +199,7 @@ TYPE
 PROCEDURE ParseHidDescriptor(descriptor : Usbdi.BufferPtr) : HidDescriptor;
 VAR hid : HidDescriptor;  i : LONGINT;
 BEGIN
-	IF (descriptor # NIL) & (LEN(descriptor) >= 8) THEN
+	IF (descriptor # NIL) & (LEN(descriptor) >= 9) THEN
 		NEW(hid);
 		hid.bLength := ORD(descriptor[0]);
 		hid.bDescriptorType := ORD(descriptor[1]);
@@ -207,18 +207,18 @@ BEGIN
 		hid.bCountryCode := ORD(descriptor[4]);
 		hid.bNumDescriptors := ORD(descriptor[5]);
 		hid.bClassDescriptorType := ORD(descriptor[6]);
-		hid.wDescriptorLength := ORD(descriptor[7]);
+		hid.wDescriptorLength := ORD(descriptor[7]) + LONGINT(ORD(descriptor[8]))*100H;
 
 		(* Parse the optional descriptors if there are some *)
 		IF hid.bNumDescriptors > 1 THEN
-			IF LEN(descriptor) >= (3 * (hid.bNumDescriptors-2)) + 7 THEN
+			IF LEN(descriptor) < (3 * (hid.bNumDescriptors-1)) + 9 THEN
 				KernelLog.String("UsbHid: Warning: HID descriptor too short"); KernelLog.Ln;
 				RETURN hid;
 			END;
 			NEW(hid.optionalDescriptors, hid.bNumDescriptors-1);
 			FOR i := 0 TO hid.bNumDescriptors-2 DO
-				hid.optionalDescriptors[i].bDescriptorType := ORD(descriptor[(3 * i) + 6]);
-				hid.optionalDescriptors[i].wDescriptorLength := ORD(descriptor[(3 * i) + 7]);
+				hid.optionalDescriptors[i].bDescriptorType := ORD(descriptor[(3 * i) + 9]);
+				hid.optionalDescriptors[i].wDescriptorLength := ORD(descriptor[(3 * i) + 10]) + LONGINT(ORD(descriptor[(3 * i) + 11]))*100H;
 			END;
 		END;
 	END;