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;
}
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;
}
}
Aggregations