use of org.firstinspires.ftc.robotcore.internal.ftdi.FtDeviceIOException in project robotcode by OutoftheBoxFTC.
the class FtcEventLoop method getSerialNumberOfUsbDevice.
protected SerialNumber getSerialNumberOfUsbDevice(UsbDevice usbDevice) {
FtDevice ftDevice = null;
SerialNumber serialNumber = null;
try {
// note: we're not supposed to close this
FtDeviceManager manager = FtDeviceManager.getInstance(this.activityContext);
ftDevice = manager.openByUsbDevice(this.activityContext, usbDevice);
if (ftDevice != null) {
serialNumber = new SerialNumber(ftDevice.getDeviceInfo().serialNumber);
}
} catch (RuntimeException | FtDeviceIOException e) {
// RuntimeException is paranoia
// ignored
} finally {
if (ftDevice != null) {
ftDevice.close();
}
}
return serialNumber;
}
Aggregations