Exemple #1
0
        /// <summary>
        /// Writes array of bytes.
        /// </summary>
        /// <remarks>Do not write more than 3 bytes at once, RPi drivers don't support this currently.</remarks>
        /// <param name="address">Address of a destination device</param>
        /// <param name="bytes"></param>
        public void WriteBytes(int address, byte[] bytes)
        {
            int res = I2CNativeLib.WriteBytes(busHandle, address, bytes, bytes.Length);

            if (res == -1)
            {
                throw new IOException(String.Format("Error accessing address '{0}': {1}", address, UnixMarshal.GetErrorDescription(Stdlib.GetLastError())));
            }
            // HACK: removing res== -2 check because it was disrupting communications
            //if (res== -2)
            //	throw new IOException(String.Format("Error writing to address '{0}': I2C transaction failed", address));
        }
Exemple #2
0
        /// <summary>
        /// Writes array of bytes.
        /// </summary>
        /// <remarks>Do not write more than 3 bytes at once, RPi drivers don't support this currently.</remarks>
        /// <param name="address">Address of a destination device</param>
        /// <param name="bytes"></param>
        public void WriteBytes(int address, byte[] bytes)
        {
            int res = I2CNativeLib.WriteBytes(busHandle, address, bytes, bytes.Length);

            if (res == -1)
            {
                throw new IOException(String.Format("Error accessing address '{0}': {1}", address, UnixMarshal.GetErrorDescription(Stdlib.GetLastError())));
            }
            if (res == -2)
            {
                throw new IOException(String.Format("Error writing to address '{0}': I2C transaction failed", address));
            }
        }