| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 502 人关注过本帖
标题: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
快速回复:c#串口数据接收问题??求高手解释!!
数据加载中...
 
   



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

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