protected static Object[] extractMockArguments(Object[] args) { int i = 7; if (args.length > i) { Object[] mockArgs = new Object[args.length - i]; System.arraycopy(args, i, mockArgs, 0, mockArgs.length); return mockArgs; } return EMPTY_ARGS; }
@Override public void write(int ireg, byte[] data, boolean waitForCompletion) { try { synchronized (this.concurrentClientLock) { synchronized (this.callbackLock) { // Wait until we can write to the write cache while (this.writeCacheStatus != WRITE_CACHE_STATUS.IDLE) { this.callbackLock.wait(); } // Indicate where we want to write this.iregWriteFirst = ireg; this.cregWrite = data.length; // Indicate we are dirty so the callback will write us out this.writeCacheStatus = WRITE_CACHE_STATUS.DIRTY; // Provide the data we want to write this.writeCacheLock.lockInterruptibly(); try { System.arraycopy(data, 0, this.writeCache, dibCacheOverhead, data.length); } finally { this.writeCacheLock.unlock(); } // Let the callback know we've got new data for him this.callback.onNewDataToWrite(); if (waitForCompletion) { // Wait until the write at least issues to the device controller. This will // help make any delays/sleeps that follow a write() be more deterministically // relative to the actual I2C device write. while (writeCacheStatus != WRITE_CACHE_STATUS.IDLE) { this.callbackLock.wait(); } } } } } catch (InterruptedException e) { Util.handleCapturedInterrupt(e); } }