Search in sources :

Example 1 with FtDeviceIOException

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;
}
Also used : FtDevice(org.firstinspires.ftc.robotcore.internal.ftdi.FtDevice) FtDeviceManager(org.firstinspires.ftc.robotcore.internal.ftdi.FtDeviceManager) SerialNumber(com.qualcomm.robotcore.util.SerialNumber) FtDeviceIOException(org.firstinspires.ftc.robotcore.internal.ftdi.FtDeviceIOException)

Aggregations

SerialNumber (com.qualcomm.robotcore.util.SerialNumber)1 FtDevice (org.firstinspires.ftc.robotcore.internal.ftdi.FtDevice)1 FtDeviceIOException (org.firstinspires.ftc.robotcore.internal.ftdi.FtDeviceIOException)1 FtDeviceManager (org.firstinspires.ftc.robotcore.internal.ftdi.FtDeviceManager)1