예제 #1
0
 protected int Execute(I2CDevice.I2CTransaction action)
 {
     lock (_bus) {
         return(_bus.Execute(_config,
                             new[] {
             action
         },
                             _timeoutMilliseconds));
     }
 }
예제 #2
0
        public void Write(byte[] state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }
            if (state.Length != StateSize)
            {
                throw new ArgumentException("Length is invalid.", nameof(state));
            }

            _i2CBus.Execute(_address, bus => bus.Write(state));
        }
        public void Write(byte[] state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }
            if (state.Length != StateSize)
            {
                throw new ArgumentException("Length is invalid.", nameof(state));
            }

            // TODO: Check error handling here if device is currently not available.

            _i2CBus.Execute(_address, bus => bus.Write(state));
        }
예제 #4
0
        public HSPE16InputOnly(DeviceId id, I2CSlaveAddress address, II2CBus i2cBus, IHttpRequestController httpApi, ILogger logger)
            : base(id, new MAX7311Driver(address, i2cBus), httpApi, logger)
        {
            byte[] setupAsInputs = { 0x06, 0xFF, 0xFF };
            i2cBus.Execute(address, b => b.Write(setupAsInputs));

            FetchState();
        }
예제 #5
0
        public HSPE16InputOnly(DeviceId id, I2CSlaveAddress address, II2CBus i2cBus)
            : base(id, new MAX7311Driver(address, i2cBus))
        {
            byte[] setupAsInputs = { 0x06, 0xFF, 0xFF };
            i2cBus.Execute(address, b => b.Write(setupAsInputs));

            FetchState();
        }
        public void ExecuteCommand(I2CHardwareBridgeCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            _i2CBus.Execute(_address, command.Execute, false);
        }
예제 #7
0
        public void Write(byte[] state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }
            if (state.Length != StateSize)
            {
                throw new ArgumentException("Length is invalid.", nameof(state));
            }

            byte[] setConfigurationToOutput = { ConfigurationRegisterA, 0, 0 };
            byte[] setState = { OutputPortRegisterA, state[0], state[1] };

            _i2CBus.Execute(_address, bus =>
            {
                bus.Write(setConfigurationToOutput);
                bus.Write(setState);
            });
        }
예제 #8
0
        public void Write(byte[] state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }
            if (state.Length != StateSize)
            {
                throw new ArgumentException("Length is invalid.", nameof(state));
            }

            // TODO: Check error handling here if device is currently not available.

            byte[] setConfigurationToOutput = { ConfigurationRegisterA, 0, 0 };
            byte[] setState = { OutputPortRegisterA, state[0], state[1] };

            _i2CBus.Execute(_address, bus =>
            {
                bus.Write(setConfigurationToOutput);
                bus.Write(setState);
            });
        }
예제 #9
0
 public void Execute(II2cDeviceCommand command)
 {
     bus.Execute(address, command.Execute, true);
 }