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

            IsConnected = false;
        }
Exemple #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();
                    }
                }
            }
        }
Exemple #3
0
 /// <inheritdoc/>
 public void Dispose()
 {
     _device?.Dispose();
     _device = null !;
     _timer?.Dispose();
     _timer = null !;
 }
Exemple #4
0
        /// <summary>
        /// Cleanup
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            _i2cDevice?.Dispose();
            _i2cDevice = null !;

            base.Dispose(disposing);
        }
Exemple #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;
        }
Exemple #7
0
 public void Dispose()
 {
     _servoMotor?.Dispose();
     _servoChannel?.Dispose();
     _pca9685?.Dispose();
     _i2cDevice?.Dispose();
 }
Exemple #8
0
 /// <summary>
 /// Releases all resources used by the libPCA9685.PCA9685 object.
 /// </summary>
 public void Dispose()
 {
     if (_device != null)
     {
         SetAllOff();
     }
     _device?.Dispose();
 }
Exemple #9
0
 /// <inheritdoc/>
 public void Dispose()
 {
     if (_autoDispose)
     {
         _i2cDevice?.Dispose();
         _i2cDevice = null;
     }
 }
Exemple #10
0
 public void Dispose()
 {
     if (_i2cDevice != null)
     {
         _i2cDevice?.Dispose();
         _i2cDevice = null;
     }
 }
Exemple #11
0
 /// <inheritdoc/>
 public void Dispose()
 {
     if (_shouldDispose)
     {
         _i2cDevice?.Dispose();
         _i2cDevice = null;
     }
 }
Exemple #12
0
 /// <inheritdoc/>
 public void Dispose()
 {
     PowerOff();
     if (_autoDisposable)
     {
         _i2cDevice?.Dispose();
         _i2cDevice = null;
     }
 }
Exemple #13
0
        /// <inheritdoc/>
        public void Dispose()
        {
            if (_shouldDispose)
            {
                _controller?.Dispose();
            }

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

            i2cbus2?.Dispose();
            i2cbus2 = null;

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

            _i2cDevice?.Dispose();
            _i2cDevice = null !;
        }
Exemple #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;
            }
        }
Exemple #19
0
        protected virtual void Dispose(bool disposing)
        {
            _rawDevice?.Close();
            _rawDevice?.Dispose();
            _rawDevice = null;

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

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

            _isDisposed = true;
        }
Exemple #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;
            }
        }
Exemple #23
0
        public void Dispose()
        {
            if (_observable != null)
            {
                _observable.Dispose();
            }

            Standby();

            if (_i2cDevice != null)
            {
                _i2cDevice?.Dispose();
                _i2cDevice = null;
            }
        }
Exemple #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;
        }
Exemple #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;
        }
Exemple #27
0
 /// <inheritdoc/>
 public void Dispose()
 {
     _i2cDevice?.Dispose();
     _i2cDevice = null;
 }
Exemple #28
0
 /// <inheritdoc/>
 public void Dispose()
 {
     _i2c?.Dispose();
     _i2c = null !;
 }
Exemple #29
0
 /// <inheritdoc/>
 public void Dispose()
 {
     I2cDevice?.Dispose();
     I2cDevice = null;
 }
Exemple #30
0
 public override void Dispose()
 {
     _i2cDevice?.Dispose();
     base.Dispose();
 }