示例#1
0
        /// <summary>
        /// 打开串口
        /// </summary>
        /// <returns></returns>
        public bool Connect()
        {
            if (Port > 0)
            {
                // 关闭串口
                StaticClassReaderB.CloseSpecComPort(FrmHandle);
            }

            CommonUtils.ActiveAllCom();

            // 打开串口
            int iRet = StaticClassReaderB.AutoOpenComPort(ref Port, ref ComAdr, Baud, ref FrmHandle);

            // 串口打开成功
            if (iRet == 0)
            {
                return(true);
            }
            else
            {
                // 串口打开失败
                return(false);
            }
        }