Search in sources :

Example 1 with LynxUsbDeviceImpl

use of com.qualcomm.hardware.lynx.LynxUsbDeviceImpl in project robotcode by OutoftheBoxFTC.

the class FtcEventLoopBase method getLynxUsbDeviceForFirmwareUpdate.

protected LynxUsbDeviceContainer getLynxUsbDeviceForFirmwareUpdate(SerialNumber serialNumber) {
    // Is is it something that's already open?
    for (LynxUsbDeviceImpl lynxUsbDevice : ftcEventLoopHandler.getExtantLynxDeviceImpls()) {
        if (lynxUsbDevice.getSerialNumber().equals(serialNumber)) {
            return new LynxUsbDeviceContainer(lynxUsbDevice);
        }
    }
    // No, then open it
    try {
        RobotUsbManager robotUsbManager = HardwareDeviceManager.createUsbManager(AppUtil.getDefContext());
        RobotUsbDevice robotUsbDevice = LynxUsbUtil.openUsbDevice(robotUsbManager, serialNumber);
        return new LynxUsbDeviceContainer(robotUsbDevice);
    } catch (RobotCoreException e) {
    // ignored;
    }
    return null;
}
Also used : RobotUsbManager(com.qualcomm.robotcore.hardware.usb.RobotUsbManager) LynxUsbDeviceImpl(com.qualcomm.hardware.lynx.LynxUsbDeviceImpl) RobotCoreException(com.qualcomm.robotcore.exception.RobotCoreException) RobotUsbDevice(com.qualcomm.robotcore.hardware.usb.RobotUsbDevice)

Example 2 with LynxUsbDeviceImpl

use of com.qualcomm.hardware.lynx.LynxUsbDeviceImpl in project robotcode by OutoftheBoxFTC.

the class FtcEventLoopHandler method getExtantLynxDeviceImpls.

public List<LynxUsbDeviceImpl> getExtantLynxDeviceImpls() {
    synchronized (hardwareFactory) {
        List<LynxUsbDeviceImpl> result = new ArrayList<LynxUsbDeviceImpl>();
        HardwareMap map = hardwareMap;
        if (map != null) {
            for (LynxUsbDevice lynxUsbDevice : map.getAll(LynxUsbDevice.class)) {
                if (lynxUsbDevice.getArmingState() == RobotArmingStateNotifier.ARMINGSTATE.ARMED) {
                    result.add(lynxUsbDevice.getDelegationTarget());
                }
            }
        }
        return result;
    }
}
Also used : HardwareMap(com.qualcomm.robotcore.hardware.HardwareMap) LynxUsbDevice(com.qualcomm.hardware.lynx.LynxUsbDevice) LynxUsbDeviceImpl(com.qualcomm.hardware.lynx.LynxUsbDeviceImpl) ArrayList(java.util.ArrayList)

Aggregations

LynxUsbDeviceImpl (com.qualcomm.hardware.lynx.LynxUsbDeviceImpl)2 LynxUsbDevice (com.qualcomm.hardware.lynx.LynxUsbDevice)1 RobotCoreException (com.qualcomm.robotcore.exception.RobotCoreException)1 HardwareMap (com.qualcomm.robotcore.hardware.HardwareMap)1 RobotUsbDevice (com.qualcomm.robotcore.hardware.usb.RobotUsbDevice)1 RobotUsbManager (com.qualcomm.robotcore.hardware.usb.RobotUsbManager)1 ArrayList (java.util.ArrayList)1