diff --git a/Hardware/src/main/java/com/qualcomm/hardware/lynx/LynxModule.java b/Hardware/src/main/java/com/qualcomm/hardware/lynx/LynxModule.java index f02a92c7..2d1b31ef 100644 --- a/Hardware/src/main/java/com/qualcomm/hardware/lynx/LynxModule.java +++ b/Hardware/src/main/java/com/qualcomm/hardware/lynx/LynxModule.java @@ -1368,24 +1368,26 @@ public double getAnalogInputVoltage(int inputZ, VoltageUnit unit) */ public BulkData getBulkData() { - clearBulkCache(); - - LynxGetBulkInputDataCommand command = new LynxGetBulkInputDataCommand(this); - try - { - LynxGetBulkInputDataResponse response = command.sendReceive(); synchronized (bulkCachingLock) + { + clearBulkCache(); + + LynxGetBulkInputDataCommand command = new LynxGetBulkInputDataCommand(this); + try { - lastBulkData = new BulkData(response); - return lastBulkData; + LynxGetBulkInputDataResponse response = command.sendReceive(); + lastBulkData = new BulkData(response); + return lastBulkData; + } + catch (InterruptedException|RuntimeException|LynxNackException e) + { + handleException(e); } - } - catch (InterruptedException|RuntimeException|LynxNackException e) - { - handleException(e); - } - return LynxUsbUtil.makePlaceholderValue(new BulkData(new LynxGetBulkInputDataResponse(this))); + BulkData placeholder = LynxUsbUtil.makePlaceholderValue(new BulkData(new LynxGetBulkInputDataResponse(this))); + lastBulkData = placeholder; + return placeholder; + } } /**