/// <summary> /// Disposes the SD by tearing down any current connection and disposing the SerialPort. /// </summary> public override void Dispose() { if (!m_disposed) { Disconnect(); SwitchPower(false); m_port.Dispose(); if (null != m_power) { m_power.Dispose(); m_power = null; } m_ioCtrl = null; ForceState(BTDeviceState.UNINITIALIZED); m_disposed = true; } }
/////////////////////////////////////////////////////////////////////////// // Private helper methods /// <summary> /// A helper method to create the serial connection objects (SerialPort) and /// SDIOController. /// </summary> /// <param name="com"> /// The COM port number /// </param> /// <param name="baud"> /// The baudrate for the specified COM port /// </param> /// <returns> /// True if the objects were successfully created, false o/w /// </returns> private bool CreateSerialConnection(string com, BaudRate baud) { bool created = false; try { if (null != m_port) m_port.Dispose(); m_port = null; m_port = new SerialPort(com, (int)baud); m_port.Open(); m_ioCtrl = new SDIOController(m_port); created = true; } finally { if (!created) { if (null != m_port) { m_port.Dispose(); m_port = null; } if (null != m_ioCtrl) m_ioCtrl = null; } } return created; }