private void DisconnectDisplay(ISerialPortService pObjSerialPort) { if (pObjSerialPort != null) { lock (pObjSerialPort) { if (Connections.Count == 0 && pObjSerialPort.IsOpen()) { LogService.WriteInfo(string.Format("Desconectando puerto serial {0}...", pObjSerialPort.GetName())); pObjSerialPort.Close(); LogService.WriteInfo(string.Format("Puerto serial {0} desconectado.", pObjSerialPort.GetName())); } } } }
private void Connect(string portName) { if (string.IsNullOrEmpty(portName)) { return; } try { if (m_serialPort.IsOpen) { m_serialPort.Close(); } m_serialPort.PortName = portName; m_serialPort.Open(); } catch (IOException) { } }