public static Serial GetChannel(SerialPortNames portName) { try { foreach (Channel c in m_channels) { if (c.GetType() == typeof(Serial)) { Serial serial = c as Serial; if (serial.PortName == portName) { return(serial); } } } return(null); } catch (ComDriveExceptions ex) { throw; } catch (Exception ex) { string exceptionText = ex.GetType().ToString() + ": " + ex.Message + "\n\n" + ex.StackTrace; ComDriverLogger.LogExceptions(DateTime.Now, exceptionText); throw; } }
private void GetSerialPortNameExcute() { string[] tempNameArray = SerialPort.GetPortNames(); SerialPortNames.Clear(); foreach (string str in tempNameArray) { SerialPortNames.Add(str.Trim()); } }
private void CheckPortName(SerialPortNames portName) { string[] portNames = SerialPort.GetPortNames(); if (!portNames.Contains(portName.ToString())) { throw new ComDriveExceptions("Specified Serial Port doesn't exist!", ComDriveExceptions.ComDriveException.CommunicationParamsException); } }
public Serial(SerialPortNames portName, BaudRate baudRate) : base(3, 3000) { m_SerialPortNames = portName; m_serialPort.DataBits = 8; m_serialPort.Parity = Parity.None; m_serialPort.StopBits = StopBits.One; m_serialPort.BaudRate = (int)baudRate; }
public Serial(SerialPortNames portName, BaudRate baudRate, int retry, int timeOut, DataBits dataBits, Parity parity, StopBits stopBit) : base(retry, timeOut) { m_SerialPortNames = portName; m_serialPort.BaudRate = (int)baudRate; m_serialPort.DataBits = (int)dataBits; m_serialPort.Parity = parity; m_serialPort.StopBits = stopBit; }
public Serial(SerialPortNames portName, BaudRate baudRate, int retry, int timeOut, DataBits dataBits, Parity parity, StopBits stopBit, bool autoDetectComParams) : base(retry, timeOut) { m_SerialPortNames = portName; m_serialPort.BaudRate = (int)baudRate; m_serialPort.DataBits = (int)dataBits; m_serialPort.Parity = parity; m_serialPort.StopBits = stopBit; m_AutoDetectComParams = autoDetectComParams; }
private void RefreshPortNames() { var portNames = SerialPort.GetPortNames(); SerialPortNames.Clear(); foreach (var portName in portNames) { SerialPortNames.Add(portName); } }
private void RefreshPortNames() { try { var portNames = SerialPort.GetPortNames(); SerialPortNames.Clear(); foreach (var portName in portNames) { SerialPortNames.Add(portName); } } catch (Exception ex) { _messageBoxService.Display(ex, "Refresh Port Names"); } }
internal static bool ValidateChannelPropertyChange(Serial channel, SerialPortNames newPortName) { if (!m_channels.Contains(channel)) { return(true); } else { Serial serial = GetChannel(newPortName); if (serial == null) { return(true); } else { return(false); } } }