/// <summary> /// Dispose of the I2C device. /// </summary> public void Dispose() { i2cbus?.Dispose(); i2cbus = null; IsConnected = false; }
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(); } } } }
/// <inheritdoc/> public void Dispose() { _device?.Dispose(); _device = null !; _timer?.Dispose(); _timer = null !; }
/// <summary> /// Cleanup /// </summary> protected override void Dispose(bool disposing) { _i2cDevice?.Dispose(); _i2cDevice = null !; base.Dispose(disposing); }
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; }
public void Dispose() { _servoMotor?.Dispose(); _servoChannel?.Dispose(); _pca9685?.Dispose(); _i2cDevice?.Dispose(); }
/// <summary> /// Releases all resources used by the libPCA9685.PCA9685 object. /// </summary> public void Dispose() { if (_device != null) { SetAllOff(); } _device?.Dispose(); }
/// <inheritdoc/> public void Dispose() { if (_autoDispose) { _i2cDevice?.Dispose(); _i2cDevice = null; } }
public void Dispose() { if (_i2cDevice != null) { _i2cDevice?.Dispose(); _i2cDevice = null; } }
/// <inheritdoc/> public void Dispose() { if (_shouldDispose) { _i2cDevice?.Dispose(); _i2cDevice = null; } }
/// <inheritdoc/> public void Dispose() { PowerOff(); if (_autoDisposable) { _i2cDevice?.Dispose(); _i2cDevice = null; } }
/// <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; }
/// <inheritdoc/> public void Dispose() { _i2cDevice?.Dispose(); _i2cDevice = null !; if (_shouldDispose) { _controller?.Dispose(); _controller = null; } }
/// <summary> /// Dispose of the <see cref="ADCDifferentialPi" /> instance. /// </summary> public void Dispose() { i2cbus1?.Dispose(); i2cbus1 = null; i2cbus2?.Dispose(); i2cbus2 = null; IsConnected = false; }
/// <inheritdoc/> public void Dispose() { if (_shouldDispose) { _gpioController?.Dispose(); _gpioController = null; } _i2cDevice?.Dispose(); _i2cDevice = null !; }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { Device?.Dispose(); Device = null; } disposedValue = true; } }
protected virtual void Dispose(bool disposing) { _rawDevice?.Close(); _rawDevice?.Dispose(); _rawDevice = null; if (disposing) { _peripheralManagerService?.Dispose(); _peripheralManagerService = null; } }
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; }
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; } }
public void Dispose() { if (_observable != null) { _observable.Dispose(); } Standby(); if (_i2cDevice != null) { _i2cDevice?.Dispose(); _i2cDevice = null; } }
/// <inheritdoc/> public void Dispose() { if (_shouldDispose) { _controller?.Dispose(); _controller = null; } else if (_controller?.IsPinOpen(_pin) ?? false) { _controller.ClosePin(_pin); } _i2cDevice?.Dispose(); _i2cDevice = null; }
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; }
/// <inheritdoc/> public void Dispose() { _i2cDevice?.Dispose(); _i2cDevice = null; }
/// <inheritdoc/> public void Dispose() { _i2c?.Dispose(); _i2c = null !; }
/// <inheritdoc/> public void Dispose() { I2cDevice?.Dispose(); I2cDevice = null; }
public override void Dispose() { _i2cDevice?.Dispose(); base.Dispose(); }