/// <summary>
        ///     Dispose of the I2C device.
        /// </summary>
        public void Dispose()
        {
            i2cbus?.Dispose();
            i2cbus = null;

            IsConnected = false;
        }
Exemplo n.º 2
0
        private II2CTransferResult Execute(I2CSlaveAddress address, Func <I2cDevice, I2cTransferResult> action, bool useCache = true)
        {
            lock (_deviceCache)
            {
                I2cDevice device = null;
                try
                {
                    device = GetDevice(address.Value, useCache);
                    var result = action(device);

                    if (result.Status != I2cTransferStatus.FullTransfer)
                    {
                        _log.Warning($"Transfer failed. Address={address.Value} Status={result.Status} TransferredBytes={result.BytesTransferred}");
                    }

                    return(WrapResult(result));
                }
                catch (Exception exception)
                {
                    // Ensure that the application will not crash if some devices are currently not available etc.
                    _log.Warning(exception, $"Error while accessing I2C device with address {address}.");
                    return(new I2CTransferResult(I2CTransferStatus.UnknownError, 0));
                }
                finally
                {
                    if (!useCache)
                    {
                        device?.Dispose();
                    }
                }
            }
        }
Exemplo n.º 3
0
 /// <inheritdoc/>
 public void Dispose()
 {
     _device?.Dispose();
     _device = null !;
     _timer?.Dispose();
     _timer = null !;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Cleanup
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            _i2cDevice?.Dispose();
            _i2cDevice = null !;

            base.Dispose(disposing);
        }
Exemplo n.º 5
0
 public void Dispose()
 {
     _i2cDevice?.Dispose();
     _i2cDevice = null;
     _masterGpioController?.Dispose();
     _masterGpioController = null;
 }
        /// <summary>
        /// Protected implementation of Dispose pattern
        /// </summary>
        /// <param name="disposing"></param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                handle.Dispose();
                // Free any other managed objects here.
                adc?.Dispose();
                adc = null;

                dac?.Dispose();
                dac = null;

                IOi2cbus?.Dispose();
                IOi2cbus = null;

                RTCi2cbus?.Dispose();
                RTCi2cbus = null;

                IsConnected = false;
            }

            // Free any unmanaged objects here.
            //
            disposed = true;
        }
Exemplo n.º 7
0
 public void Dispose()
 {
     _servoMotor?.Dispose();
     _servoChannel?.Dispose();
     _pca9685?.Dispose();
     _i2cDevice?.Dispose();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Releases all resources used by the libPCA9685.PCA9685 object.
 /// </summary>
 public void Dispose()
 {
     if (_device != null)
     {
         SetAllOff();
     }
     _device?.Dispose();
 }
Exemplo n.º 9
0
 /// <inheritdoc/>
 public void Dispose()
 {
     if (_autoDispose)
     {
         _i2cDevice?.Dispose();
         _i2cDevice = null;
     }
 }
Exemplo n.º 10
0
 public void Dispose()
 {
     if (_i2cDevice != null)
     {
         _i2cDevice?.Dispose();
         _i2cDevice = null;
     }
 }
Exemplo n.º 11
0
 /// <inheritdoc/>
 public void Dispose()
 {
     if (_shouldDispose)
     {
         _i2cDevice?.Dispose();
         _i2cDevice = null;
     }
 }
Exemplo n.º 12
0
 /// <inheritdoc/>
 public void Dispose()
 {
     PowerOff();
     if (_autoDisposable)
     {
         _i2cDevice?.Dispose();
         _i2cDevice = null;
     }
 }
Exemplo n.º 13
0
        /// <inheritdoc/>
        public void Dispose()
        {
            if (_shouldDispose)
            {
                _controller?.Dispose();
            }

            _i2cDevice?.Dispose();
        }
Exemplo n.º 14
0
 public void Dispose()
 {
     I2cDevice?.Dispose();
     I2cDevice = null;
     Pwm?.Dispose();
     Pwm = null;
     Gpio?.Dispose();
     Gpio = null;
 }
Exemplo n.º 15
0
 /// <inheritdoc/>
 public void Dispose()
 {
     _i2cDevice?.Dispose();
     _i2cDevice = null !;
     if (_shouldDispose)
     {
         _controller?.Dispose();
         _controller = null;
     }
 }
Exemplo n.º 16
0
        /// <summary>
        ///     Dispose of the <see cref="ADCDifferentialPi" /> instance.
        /// </summary>
        public void Dispose()
        {
            i2cbus1?.Dispose();
            i2cbus1 = null;

            i2cbus2?.Dispose();
            i2cbus2 = null;

            IsConnected = false;
        }
Exemplo n.º 17
0
        /// <inheritdoc/>
        public void Dispose()
        {
            if (_shouldDispose)
            {
                _gpioController?.Dispose();
                _gpioController = null;
            }

            _i2cDevice?.Dispose();
            _i2cDevice = null !;
        }
Exemplo n.º 18
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    Device?.Dispose();
                    Device = null;
                }
                disposedValue = true;
            }
        }
Exemplo n.º 19
0
        protected virtual void Dispose(bool disposing)
        {
            _rawDevice?.Close();
            _rawDevice?.Dispose();
            _rawDevice = null;

            if (disposing)
            {
                _peripheralManagerService?.Dispose();
                _peripheralManagerService = null;
            }
        }
Exemplo n.º 20
0
 private void Dispose(bool disposing)
 {
     if (!_isDisposed)
     {
         if (disposing)
         {
             _device?.Dispose();
             _interruptPin.ValueChanged -= OnRaiseInterrupts;
             _interruptPin.Dispose();
         }
         _isDisposed = true;
     }
 }
Exemplo n.º 21
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                _i2cDevice?.Dispose();
            }

            _isDisposed = true;
        }
Exemplo n.º 22
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _i2cdevice?.Dispose();
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Exemplo n.º 23
0
        public void Dispose()
        {
            if (_observable != null)
            {
                _observable.Dispose();
            }

            Standby();

            if (_i2cDevice != null)
            {
                _i2cDevice?.Dispose();
                _i2cDevice = null;
            }
        }
Exemplo n.º 24
0
        /// <inheritdoc/>
        public void Dispose()
        {
            if (_shouldDispose)
            {
                _controller?.Dispose();
                _controller = null;
            }
            else if (_controller?.IsPinOpen(_pin) ?? false)
            {
                _controller.ClosePin(_pin);
            }

            _i2cDevice?.Dispose();
            _i2cDevice = null;
        }
Exemplo n.º 25
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    _device?.Dispose();
                    _device = null;
                    // TODO: dispose managed state (managed objects).
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                _disposedValue = true;
            }
        }
        /// <summary>
        /// Protected implementation of Dispose pattern
        /// </summary>
        /// <param name="disposing"></param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                handle.Dispose();
                // Free any other managed objects here.
                i2cbus1?.Dispose();
                i2cbus1 = null;

                i2cbus2?.Dispose();
                i2cbus2 = null;

                IsConnected = false;
            }

            // Free any unmanaged objects here.
            //
            disposed = true;
        }
Exemplo n.º 27
0
 /// <inheritdoc/>
 public void Dispose()
 {
     _i2cDevice?.Dispose();
     _i2cDevice = null;
 }
Exemplo n.º 28
0
 /// <inheritdoc/>
 public void Dispose()
 {
     _i2c?.Dispose();
     _i2c = null !;
 }
Exemplo n.º 29
0
 /// <inheritdoc/>
 public void Dispose()
 {
     I2cDevice?.Dispose();
     I2cDevice = null;
 }
Exemplo n.º 30
0
 public override void Dispose()
 {
     _i2cDevice?.Dispose();
     base.Dispose();
 }