Example #1
0
        /// <summary>
        /// 串口对手初始化
        /// </summary>
        private void InitSerialPort()
        {
            //初始化串口配置类
            configCom1 = new ConfigCom(this.cbSerial1, this.cbBaudRate1, this.cbDataBits1, this.cbStop1, this.cbParity1);
            configCom2 = new ConfigCom(this.cbSerial2, this.cbBaudRate2, this.cbDataBits2, this.cbStop2, this.cbParity2);

            //初始化串口助手类
            serialPort1 = new SerialPortHelper();
            serialPort1.ConfigSerialPort = configCom1.GetConfigComData();
            serialPort1.BindSerialPortDataReceivedProcessEvent(new SerialPortHelper.DelegateSerialPortDataReceivedProcessEvent(SerialPortDataReceivedProcess));
            serialPort1.BindSerialPortErrorEvent(new SerialPortHelper.DelegateSerialPortErrorEvent(SerialPortErrorProcess));
            serialPort1.SerialReceviedTimeInterval = 40;
            serialPort1.SerialWriteTimeInterval    = 1;
            serialPort1.SerialReceviedLengthMax    = 1024;
            serialPort1.SerialMark = "串口1";

            serialPort2 = new SerialPortHelper();
            serialPort2.ConfigSerialPort = configCom1.GetConfigComData();
            serialPort2.BindSerialPortDataReceivedProcessEvent(new SerialPortHelper.DelegateSerialPortDataReceivedProcessEvent(SerialPortDataReceivedProcess));
            serialPort2.BindSerialPortErrorEvent(new SerialPortHelper.DelegateSerialPortErrorEvent(SerialPortErrorProcess));
            serialPort2.SerialReceviedTimeInterval = 40;
            serialPort2.SerialWriteTimeInterval    = 1;
            serialPort2.SerialReceviedLengthMax    = 1024;
            serialPort2.SerialMark = "串口2";
        }
Example #2
0
 /// <summary>
 /// SerialPortHelper初始化
 /// </summary>
 private void InitSerialPortHelper()
 {
     spb = new SerialPortHelper();
     spb.ConfigSerialPort = cc.GetConfigComData();
     spb.BindSerialPortDataReceivedProcessEvent(new SerialPortHelper.DelegateSerialPortDataReceivedProcessEvent(SerialPortDataReceivedProcess));
     spb.BindSerialPortErrorEvent(new SerialPortHelper.DelegateSerialPortErrorEvent(SerialPortErrorProcess));
     spb.SerialReceviedTimeInterval = 40;
     spb.SerialWriteTimeInterval    = 1;
     spb.SerialReceviedLengthMax    = 1024;
 }
Example #3
0
        /// <summary>
        /// 初始化串口助手
        /// </summary>
        private void InitSerialPortHelper()
        {
            //实例化串口配置
            configCom          = new ConfigCom(comboSerial);
            configCom.PortName = comboSerial.Text;
            configCom.BaudRate = 115200;
            configCom.DataBits = 8;
            configCom.StopBits = StopBits.One;
            configCom.Parity   = Parity.None;

            //设置串口搜索默认值
            configCom.SetSerialPortDefaultInfo("USB 串行设备"); //TI CC2540 USB CDC Serial Port
            configCom.AddSerialPortDefaultInfo("TI CC2540 USB CDC Serial Port");

            //实例化串口助手
            serialPortHelper = new SerialPortHelper(configCom.GetConfigComData());
            serialPortHelper.BindSerialPortDataReceivedProcessEvent(new SerialPortHelper.DelegateSerialPortDataReceivedProcessEvent(SerialPortDataReceivedProcess));
            serialPortHelper.BindSerialPortErrorEvent(new SerialPortHelper.DelegateSerialPortErrorEvent(SerialPortErrorProcess));
            serialPortHelper.SerialReceviedTimeInterval = 40;
            serialPortHelper.SerialWriteTimeInterval    = 200;
            serialPortHelper.SerialReceviedLengthMax    = 1024;
        }