Example #1
0
        public static ushort[] i2cWordData(int index, byte address, int length)
        {
            Monitor.Enter(sLock);
            if (sIsOpen == false)
            {
                Monitor.Exit(sLock);
                return(null);
            }

            try
            {
                var pByteArrayData = SMBusController.getI2CWordData(index, address, length);
                var datas          = SMBusController.getBytes(pByteArrayData);
                SMBusController.deleteByteArrayData(pByteArrayData);

                var retData = new ushort[length];
                for (int i = 0; i < length; i++)
                {
                    retData[i] = BitConverter.ToUInt16(datas, i * 2);
                }
                Monitor.Exit(sLock);
                return(retData);
            }
            catch { }
            Monitor.Exit(sLock);
            return(null);
        }
Example #2
0
        public static byte[] i2cDetect(int index)
        {
            Monitor.Enter(sLock);
            if (sIsOpen == false)
            {
                Monitor.Exit(sLock);
                return(null);
            }

            try
            {
                var pByteArrayData = SMBusController.getI2CDetect(index);
                var retData        = SMBusController.getBytes(pByteArrayData);
                SMBusController.deleteByteArrayData(pByteArrayData);
                Monitor.Exit(sLock);
                return(retData);
            }
            catch { }
            Monitor.Exit(sLock);
            return(null);
        }
Example #3
0
        public static byte[] i2cByteData(int index, byte address, int length)
        {
            Monitor.Enter(sLock);
            if (sIsOpen == false)
            {
                Monitor.Exit(sLock);
                return(null);
            }

            try
            {
                var pByteArrayData = SMBusController.getI2CByteData(index, address, length);
                var retData        = SMBusController.getBytes(pByteArrayData);
                SMBusController.deleteByteArrayData(pByteArrayData);
                Monitor.Exit(sLock);
                return(retData);
            }
            catch { }
            Monitor.Exit(sLock);
            return(null);
        }