日期:2014-05-17  浏览次数:20999 次

c#串口出错
1.
点击上面的实时数据,下面是方法
private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if (this.panel1.Controls.Count > 0)
            {
                Control ctl = this.panel1.Controls[0];
                if (ctl is 实时数据)
                {
                    实时数据 fmChild = ctl as 实时数据;
                    fmChild.ClosePort();
                }
                else if (ctl is 单灯控制)
                {
                    单灯控制 fmChild = ctl as 单灯控制;
                    fmChild.Close();
                }
            }
            this.panel1.Controls.Clear();
            实时数据 realdata = new 实时数据();
            realdata.FormBorderStyle = FormBorderStyle.None;
            realdata.TopLevel = false;
            this.panel1.Controls.Add(realdata);
            realdata.Show();
        }
2.实时数据form页面的不断地调用串口配置方法代码如下:
//串口参数设置
        public void SetPot(SerialPort sp, string PortName, string BaudRate, string DateBit, string StopBit, string CheckBit)
        {