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 close() throws Exception { dev.release_interface(0); dev.close(); }