zoukankan      html  css  js  c++  java
  • 串口

    jacklee

    MSCOMM的到有一些,昨天测试过
    初使化:
                axms.CommPort =1;
                axms.Settings ="9600,n,8,1";
                //axms.InputMode=InputModeConstants.comInputModeText;
                axms.InputMode =InputModeConstants.comInputModeBinary ;
                axms.InputLen =1024;
                axms.OutBufferSize=256;
                axms.RThreshold=1;
                axms.PortOpen =true;

    发数据:
                byte[] Msg=new byte[3];
                Msg[0]=100;//Convert.ToByte ('a');
                Msg[1]=78;//Convert.ToByte ('b');
                Msg[2]=105;//Convert.ToByte ('c');
                axms.Output=Msg;
    注:发数据后ONCOMM事件马上会检测到有数据发送事件,你可以去提取


    提取及事件测试:
            private void axms_OnComm(object sender, System.EventArgs e)
            {
                switch(axms.CommEvent )
                {
                    case (short)OnCommConstants.comEvCD :
                        textBox1.Text +="CD\r\n";
                        break;
                    case (short)OnCommConstants.comEvCTS:
                        textBox1.Text +="CTS\r\n";
                        break;
                    case (short)OnCommConstants.comEvDSR:
                        textBox1.Text +="DSR\r\n";
                        break;
                    case (int)OnCommConstants.comEvReceive:  //提取
                        ComMsg="";
                        byte[] tp;
                        object tobj;
                        axms.InputLen =0;
                        tobj=axms.Input;
                        tp=(byte[])tobj;
                        for(int i=0;i<tp.Length-1;i++)
                        {
                            ComMsg+=tp[i].ToString ("X")+" ";
                        }
                        textBox1.Text +="Received datas/"+ComMsg+"\r\n";
                        break;
                    case (int)OnCommConstants.comEvSend :
                        textBox1.Text +="Message Send.\r\n";
                        break;
                    default:
                        textBox1.Text +="Default [else] Event\r\n";
                        break;
                }
                textBox1.Text +="Comm Event--\r\n";
    }

  • 相关阅读:
    [windbg] 进程、线程
    [Windows 驱动开发] 驱动中获取函数地址
    [DuiLib] 入坑资料收集
    [Windows 驱动开发] 获取驱动详细信息
    基于模板的SPS展示层定制
    关于工作角色的一个新的思考
    中小企业IT建设的有关思路
    定制SharePoint Portal之去除帮助链接
    大客户谈判技巧关于IT行业售前工作
    细节决定成败
  • 原文地址:https://www.cnblogs.com/lgzh3/p/890172.html
Copyright © 2011-2022 走看看