Search in sources :

Example 1 with LynxI2cWriteReadMultipleBytesCommand

use of com.qualcomm.hardware.lynx.commands.core.LynxI2cWriteReadMultipleBytesCommand in project robotcode by OutoftheBoxFTC.

the class LynxI2cDeviceSynchV2 method readTimeStamped.

/*
     * Supporting firmware version XX.XX.XX
     */
@Override
public synchronized TimestampedData readTimeStamped(final int ireg, final int creg) {
    LynxI2cDeviceSynchV2 deviceHavingProblems = null;
    boolean reportUnhealthy;
    try {
        return acquireI2cLockWhile(new Supplier<TimestampedData>() {

            @Override
            public TimestampedData get() throws InterruptedException, RobotCoreException, LynxNackException {
                LynxCommand<?> tx = new LynxI2cWriteReadMultipleBytesCommand(getModule(), bus, i2cAddr, ireg, creg);
                tx.send();
                readTimeStampedPlaceholder.reset();
                return pollForReadResult(i2cAddr, ireg, creg);
            }
        });
    } catch (InterruptedException | RobotCoreException | RuntimeException e) {
        handleException(e);
    } catch (LynxNackException e) {
        /*
             * This is a possible device problem, go ahead and tell makeFakeData to warn.
             */
        deviceHavingProblems = this;
        handleException(e);
    }
    return readTimeStampedPlaceholder.log(TimestampedI2cData.makeFakeData(deviceHavingProblems, getI2cAddress(), ireg, creg));
}
Also used : TimestampedData(com.qualcomm.robotcore.hardware.TimestampedData) LynxI2cWriteReadMultipleBytesCommand(com.qualcomm.hardware.lynx.commands.core.LynxI2cWriteReadMultipleBytesCommand) RobotCoreException(com.qualcomm.robotcore.exception.RobotCoreException) LynxCommand(com.qualcomm.hardware.lynx.commands.LynxCommand)

Aggregations

LynxCommand (com.qualcomm.hardware.lynx.commands.LynxCommand)1 LynxI2cWriteReadMultipleBytesCommand (com.qualcomm.hardware.lynx.commands.core.LynxI2cWriteReadMultipleBytesCommand)1 RobotCoreException (com.qualcomm.robotcore.exception.RobotCoreException)1 TimestampedData (com.qualcomm.robotcore.hardware.TimestampedData)1