/// <summary> /// Dispose this object /// </summary> public void Dispose() { foreach (I2cDevice device in _i2CDevices) { try { device.Dispose(); } finally {;; } } _i2CDevices = null; _self = null; }
/// <summary> /// Create the instance of the shared bus for the given device selector /// </summary> /// <param name="selector"></param> /// <returns></returns> public static I2CSharedBus CreateInstance(string selector) { lock (typeof(I2CSharedBus)) { if (selector == null || selector.Trim().Length == 0) { throw new ArgumentException("selector is null"); } if (I2cDevice.GetDeviceSelector().ToUpper().IndexOf(selector.ToUpper()) < 0) { throw new ArgumentException("Invalid device selector"); } if (_self != null) { _self.Dispose(); } _self = new I2CSharedBus(); _self.SetDeviceSelector(selector); } return(_self); }