I2CDevice.TryRead | tryRead method

Reads data from the inter-integrated circuit (I²C) bus on which the device is connected into the specified buffer, and returns information about the success of the operation that you can use for error handling.

Syntax

var result = i2cDevice.tryRead();
var readBuffer = result.readBuffer;
var bytesTransferred = result.bytesTransferred;
var i2cTransferStatus = result.i2cTransferStatus;
public I2CTransferStatus TryRead(
  out byte[] readBuffer, 
  out uint bytesTransferred
)
Public Function TryRead(
  <OutAttribute> readBuffer As Byte(),  
  <OutAttribute> ByRef bytesTransferred As UInteger 
) As I2CTransferStatus
public:
I2CTransferStatus TryRead(
  Array<unsigned char>^ readBuffer, 
  [OutAttribute] unsigned int bytesTransferred
)

Parameters

  • readBuffer (out parameter)
    Type: array of Number [JavaScript] | System.Byte[] [.NET] | Platform::Array<uint8> [C++]

    The buffer to which you want to read the data from the I²C bus. The length of the buffer determines how much data to request from the device.

  • bytesTransferred (out parameter)
    Type: Number [JavaScript] | System.UInt32 [.NET] | uint32 [C++]

    The actual number of bytes that the read operation read into the buffer. If the return value is I2CTransferStatus.PartialTransfer, this value may be less than the number of bytes in the buffer that you specified in the readBuffer parameter.

Return value

Type: I2CTransferStatus

A value that indicates if the read operation read the full number of bytes that the method requested to the buffer, or the reason that the full transfer did not succeed.

Requirements (device family)

Device family

Universal

API contract

Windows.Devices.DevicesLowLevelContract, introduced version 1.0

Namespace

Windows.Devices.I2C Windows::Devices::I2C [C++]

Metadata

Windows.Devices.DevicesLowLevelContract.winmd

See also

I2CDevice

Read

TryWriteRead

TryWrite

I2CTransferStatus