/// <summary> /// 设置波特率 /// </summary> /// <returns></returns> public static List <SPParameterClass <int> > SetBaudRateValues() { try { List <SPParameterClass <int> > lst_sParameterClass = new List <SPParameterClass <int> >(); foreach (SerialPortBaudRates rate in Enum.GetValues(typeof(SerialPortBaudRates))) { SPParameterClass <int> i_sParameterClass = new SPParameterClass <int>(); i_sParameterClass.Name = ((int)rate).ToString(); i_sParameterClass.Value = (int)rate; lst_sParameterClass.Add(i_sParameterClass); } return(lst_sParameterClass); } catch (Exception) { throw; } }
/// <summary> /// 获取当前可用PortName /// </summary> /// <returns></returns> public static List <SPParameterClass <string> > GetPortList() { try { List <SPParameterClass <string> > lst_sParameterClass = new List <SPParameterClass <string> >(); foreach (string data in SerialPort.GetPortNames()) { SPParameterClass <string> i_sParameterClass = new SPParameterClass <string>(); i_sParameterClass.Name = data; i_sParameterClass.Value = data; lst_sParameterClass.Add(i_sParameterClass); } return(lst_sParameterClass); } catch (Exception) { throw; } }