-
-
Save ligi/65731466aa0a45934fe4 to your computer and use it in GitHub Desktop.
create a usb-device filter from vendor:product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CreateDeviceFilter { | |
private final static String TEMPLATE = "<usb-device \n" + | |
"product-id=\"$PRODUCT_ID\" \n" + | |
"vendor-id=\"$VENDOR_ID\" />"; | |
public static void main(String[] args) { | |
if (args.length != 1) { | |
System.out.println("need to pass USB vendor/product as argument like this 0e79:15c0"); | |
return; | |
} | |
final String[] vendorProduct = args[0].split(":"); | |
final int vendor = Integer.parseInt(vendorProduct[0], 16); | |
final int product = Integer.parseInt(vendorProduct[1], 16); | |
String out = TEMPLATE.replace("$PRODUCT_ID", Integer.toString(product)); | |
out = out.replace("$VENDOR_ID", Integer.toString(vendor)); | |
System.out.print(out); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment