Skip to content

Instantly share code, notes, and snippets.

@ligi
Created September 15, 2014 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ligi/65731466aa0a45934fe4 to your computer and use it in GitHub Desktop.
Save ligi/65731466aa0a45934fe4 to your computer and use it in GitHub Desktop.
create a usb-device filter from vendor:product
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