private void btnSaveConfig_Click(object sender, EventArgs e)
 {
     ConfigManager.SaveSerialPortConfigurnation(cmbPortName.Text,
                                                cmbBaudRate.Text,
                                                cmbParity.Text,
                                                cmbDataBits.Text,
                                                cmbStopBits.Text);
     StaticSerialPort.resetStaticSerialPort();
     this.Close();
 }
 public static SerialPort getStaticSerialPort()
 {
     if (StaticSerialPort.comport == null)
     {
         StaticSerialPort.comport = new SerialPort();
         comport.DataReceived    += StaticSerialPort.port_DataReceived;
         StaticSerialPort.resetStaticSerialPort();//使用统一配置参数
     }
     return(StaticSerialPort.comport);
 }
示例#3
0
        private void btnSaveConfig_Click(object sender, EventArgs e)
        {
            //ConfigManager.SaveSerialPortConfigurnation(cmbPortName.Text,
            //                                 cmbBaudRate.Text,
            //                                 cmbParity.Text,
            //                                 cmbDataBits.Text,
            //                                 cmbStopBits.Text);


            serialPortConfig config = new serialPortConfig("default", cmbPortName.Text,
                                                           cmbBaudRate.Text,
                                                           cmbParity.Text,
                                                           cmbDataBits.Text,
                                                           cmbStopBits.Text);

            serialPortConfig.saveConfig(config);
            //MessageBox.Show("保存完成!", "串口设置");
            StaticSerialPort.resetStaticSerialPort();
            this.Close();
        }