I2CDevice.TryWrite | tryWrite method

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

Syntax


var result = i2cDevice.tryWrite(writeBuffer);
var bytesTransferred = result.bytesTransferred;
var i2cTransferStatus = result.i2cTransferStatus;

Parameters

writeBuffer

Type: array of Number [JavaScript] | System.Byte[] [.NET] | Platform::Array<uint8> [C++]

A buffer that contains the data that you want to write to the I²C device. This data should not include the bus address.

bytesTransferred (out parameter)

Type: Number [JavaScript] | System.UInt32 [.NET] | uint32 [C++]

The actual number of bytes that the write operation transferred to the I²C device. 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 writeBuffer parameter.

Return value

Type: I2CTransferStatus

A value that indicates if the write operation transferred the full buffer to the I²C device, 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
Write
TryRead
TryWriteRead
I2CTransferStatus

 

 

Show: