//设置端口信息
        void SetSeriport()
        {
            try
            {

                serialport.PortName = Com.Text;
                serialport.BaudRate = int.Parse(BaudRate.Text);
                serialport.DataBits = int.Parse(Databits.Text);
                if (ParityCheck.Text.ToUpper() == "NONE")
                    serialport.Parity = Parity.None;
                else if (ParityCheck.Text.ToUpper() == "ODD")
                    serialport.Parity = Parity.Odd;
                else
                    serialport.Parity = Parity.Even;
                if (Stopbits.Text == "1")
                    serialport.StopBits = StopBits.One;
                else if (Stopbits.Text == "1.5")
                    serialport.StopBits = StopBits.OnePointFive;

                serialport.ReadTimeout = 100;
                serialport.WriteTimeout = 100;

                modbus = new Modbus(serialport);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
        void SetSeriport()
        {
            try
            {

                serialport.PortName = Com.Text;
                serialport.BaudRate = int.Parse(BaudRate.Text);
                serialport.DataBits = int.Parse(Databits.Text);
                if (ParityCheck.Text.ToUpper() == "NONE")
                    serialport.Parity = Parity.None;
                else if (ParityCheck.Text.ToUpper() == "ODD")
                    serialport.Parity = Parity.Odd;
                else
                    serialport.Parity = Parity.Even;

                if (Stopbits.Text == "1")
                    serialport.StopBits = StopBits.One;
                else if (Stopbits.Text == "1.5")
                    serialport.StopBits = StopBits.OnePointFive;

                serialport.ReadTimeout = 100;
                serialport.WriteTimeout = 100;
                //serialport.Open();

                //serialport.DiscardInBuffer();
                //serialport.DiscardOutBuffer();
                modbus = new Modbus(serialport);

                //serialport.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.Serial_Comm_Receive_Data);

                //serialport.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }