From: Daniel Schaal Date: Tue, 9 May 2017 15:36:52 +0000 (+0200) Subject: Parse vendor-id and product-id as hexadecimal values X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2606541de1a91657c0001c0ea573d537069e2332;p=sigrok-androidutils.git Parse vendor-id and product-id as hexadecimal values Fixes #932 --- diff --git a/src/org/sigrok/androidutils/UsbSupplicant.java b/src/org/sigrok/androidutils/UsbSupplicant.java index 0f219a8..eaec3d6 100644 --- a/src/org/sigrok/androidutils/UsbSupplicant.java +++ b/src/org/sigrok/androidutils/UsbSupplicant.java @@ -106,7 +106,7 @@ public class UsbSupplicant for (int i = 0; i < count; i++) { String name = parser.getAttributeName(i); // All attribute values are ints - int value = Integer.parseInt(parser.getAttributeValue(i)); + int value = parseAttribute(name, parser.getAttributeValue(i)); if ("vendor-id".equals(name)) { vendorId = value; @@ -124,6 +124,14 @@ public class UsbSupplicant deviceClass, deviceSubclass, deviceProtocol); } + private static int parseAttribute(String name, String value) { + // vendor-id and product-id are in hexadecimal format. + if ("vendor-id".equals(name) || "product-id".equals(name)) + return Integer.parseInt(value, 16); + else + return Integer.parseInt(value); + } + private boolean matches(int clasz, int subclass, int protocol) { return ((mClass == -1 || clasz == mClass) && (mSubclass == -1 || subclass == mSubclass) &&