/// <summary> /// Close the communication port. /// </summary> /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.CloseCommunication() method is /// not CommunicationError.Success.</exception> public virtual void CloseCommunication(Protocol protocol) { CommunicationError errorCode = CommunicationError.UnknownError; try { errorCode = (CommunicationError)m_CommDevice.Close(); } catch (Exception) { errorCode = CommunicationError.SystemException; throw new CommunicationException(Resources.EMPortCloseFailed, errorCode); } if (DebugMode.Enabled == true) { DebugMode.CloseCommunication_t closeCommunication = new DebugMode.CloseCommunication_t(protocol, errorCode); DebugMode.Write(closeCommunication.ToXML()); } }
/// <summary> /// Close the communication port. /// </summary> /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.CloseCommunication() method is /// not CommunicationError.Success.</exception> public virtual void CloseCommunication(Protocol protocol) { // Check that the function delegate has been initialized. Debug.Assert(m_CloseCommunication != null, "CommunicationParent.CloseCommunication() - [m_CloseCommunication != null]"); CommunicationError errorCode = CommunicationError.UnknownError; try { errorCode = (CommunicationError)m_CloseCommunication((short)protocol); } catch (Exception) { errorCode = CommunicationError.SystemException; throw new CommunicationException(Resources.EMPortCloseFailed, errorCode); } if (DebugMode.Enabled == true) { DebugMode.CloseCommunication_t closeCommunication = new DebugMode.CloseCommunication_t(protocol, errorCode); DebugMode.Write(closeCommunication.ToXML()); } if (errorCode != CommunicationError.Success) { throw new CommunicationException(Resources.EMPortCloseFailed, errorCode); } }