/// <summary> /// Writes array of bytes. /// </summary> /// <param name="address">Address of a destination device</param> /// <param name="bytes">The bytes.</param> /// <exception cref="IOException">Thrown when address cannot be accessed or data cannot be written.</exception> /// <remarks> /// Do not write more than 3 bytes at once, RPi drivers don't support this currently. /// </remarks> public void WriteBytes(int address, byte[] bytes) { int ret = I2CNativeLib.Ioctl(this.busHandle, I2CNativeLib.I2CSlave, address); if (ret < 0) { throw new IOException(string.Format("Error accessing address '{0}'", address /*, UnixMarshal.GetErrorDescription(Stdlib.GetLastError())*/)); } ret = I2CNativeLib.Write(this.busHandle, bytes, bytes.Length); if (ret < 0) { throw new IOException(string.Format("Error writing to address '{0}': I2C transaction failed", address)); } }