/// <summary> /// Reads a single byte at the "current address" (next byte after the last operation). /// </summary> public byte[] ReadPage(int length) { // Validate if (length < 0 || length > Size) { throw new ArgumentOutOfRangeException(nameof(length)); } // Get correct I2C device for memory address and flags var device = GetI2cDeviceForMemoryAddress(0); // Read data with chunking when transfer size exceeds limit var resultBuffer = new byte[length]; var remaining = length; var offset = 0; do { // Check transfer size and reduce when necessary var transferSize = remaining; if (transferSize > I2cExtensions.MaximumTransferSize) { transferSize = I2cExtensions.MaximumTransferSize; } // Read data var buffer = I2cExtensions.ReadBytes(device, transferSize); Array.ConstrainedCopy(buffer, 0, resultBuffer, offset, transferSize); // Next transfer when necessary... remaining -= transferSize; offset += transferSize; }while (remaining > 0); return(resultBuffer); }