Ejemplo n.º 1
0
        /// <summary>
        /// 获取串口配信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetConfigComData_Click(object sender, EventArgs e)
        {
            ConfigComType configComType = cc.GetConfigComData();
            string        strMessage    = string.Format("端口号:{0} \n\r波特率:{1} \n\r数据位:{2} \n\r停止位:{3} \n\r检验位:{4} ", configComType.PortName, configComType.BaudRate, configComType.DataBits, configComType.StopBits, configComType.Parity);

            MessageBox.Show(strMessage, "串口配置 ConfigCom", MessageBoxButtons.OK);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存串口配置
        /// </summary>
        /// <param name="c">串口配置</param>
        private void SaveSerialConfig(ConfigComType c)
        {
            Dictionary <string, string> dicConfig = new Dictionary <string, string>();

            dicConfig.Add("PortName", c.PortName);
            dicConfig.Add("BaudRate", c.BaudRate.ToString());
            dicConfig.Add("DataBits", c.DataBits.ToString());
            dicConfig.Add("StopBits", c.StopBits.ToString());
            dicConfig.Add("Parity", c.Parity.ToString());
            appConfig.SetConfig(dicConfig);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 初始化串口配置控件
        /// </summary>
        private void initSerialConfig()
        {
            //实例化串口配置
            configCom = new ConfigCom(cbSerial);
            configCom.BindBaudRateObj(cbBaudRate);
            configCom.BindDataBitsObj(cbDataBits);
            configCom.BindStopBitsObj(cbStop);
            configCom.BindParityObj(cbParity);
            configCom.BaudRate = 115200;

            //初始化串口配置
            ConfigComType defConfig = GetSerialConfig();

            configCom.BaudRate = defConfig.BaudRate;
            configCom.DataBits = defConfig.DataBits;
            configCom.StopBits = defConfig.StopBits;
            configCom.Parity   = defConfig.Parity;

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