标题:c#串口数据接收问题??求高手解释!!
只看楼主
eric_lyq
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2012-8-30
结帖率:100%
 问题点数:0 回复次数:1 
c#串口数据接收问题??求高手解释!!
//串口接收数据      
private void serialPort1_DataReceived(object sender, e)
        {
            while (serialPort1.BytesToRead > 0)
            {
                ReceiveData += serialPort1.ReadExisting();
            }
            safeAddtrText(ReceiveData);//显示数据的委托
            ReceiveData = "";
        }
         //委托的实现
        private void
            safeAddtrText(string text)
        {
            if (this.InvokeRequired)
            {
                _SafeAddtrTextCall callALL =
                   delegate(string s)
                   {
                       //if (txtBoxAllReceive.Text.Length > 2048)
                       //    txtBoxAllReceive.Text = "";
                       //txtBoxAllReceive.Text += s + "  ";
                       
                       txtBoxAllReceive.AppendText(s);
                   };
                this.Invoke(callALL, text);
            }
        }
       private void button2_Click(object sender, EventArgs e)
        {
             string[] receive=new string[10];
            for (int j = 0; j < 10;)
            {
                              
                if (ReceiveData.Length == 18)
                    {
                        receive[j] = ReceiveData;
                        j++;
                    }
             }

         }
   receive[]中得到的数据一直是一个数据没改变?????????
搜索更多相关主题的帖子: private void 
2012-09-07 15:51
eric_lyq
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2012-8-30
得分:0 
顶!
2012-09-07 19:58



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-380917-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.177152 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved