public static void fillDevice() { dev = getDevice(); if (dev != null) { VendorId = HexDump.toHex(dev.getIdVendor()).toUpperCase(); DeviceId = HexDump.toHex(dev.getIdProduct()).toUpperCase(); try { dev.open(); Serial = dev.get_string_ascii((byte) 3); dev.close(); } catch (LibUsbNoDeviceException e) { dev = null; VendorId = ""; DeviceId = ""; Serial = ""; } catch (LibUsbPermissionException e) { MyLogger.getLogger().error("No permission on device. Add valid udev rules"); dev = null; VendorId = ""; DeviceId = ""; Serial = ""; } catch (LibUsbOtherException e) { dev = null; VendorId = ""; DeviceId = ""; Serial = ""; } } else { VendorId = ""; DeviceId = ""; Serial = ""; } }
public static void open() throws LibUsbNoDeviceException, LibUsbPermissionException, LibUsbOtherException, LibUsbNotFoundException, LibUsbBusyException, LibUsbInvalidParameterException { dev.open(); if (dev.kernel_driver_active(0)) dev.detach_kernel_driver(0); dev.claim_interface(0); }