public string Connect()
        {
            st = 0;

            Int16 port = 1;
            int   baud = 9600;

            byte[] ver      = new byte[30];
            byte[] hard_ver = new byte[30];

            st    = IC.lib_ver(ver);
            icdev = IC.ic_init(port, baud);
            if (icdev > 0)
            {
                ViewBag.com = "打开串口成功!";
                byte[] status = new byte[5];
                st = IC.get_status(icdev, status);
                if (st != 0)
                {
                    return("连接失败");
                }
                st = IC.srd_ver(icdev, 18, hard_ver);
                if (st == 0)
                {
                    ViewBag.SoftVer = System.Text.Encoding.ASCII.GetString(ver);
                    ViewBag.HardVer = System.Text.Encoding.ASCII.GetString(hard_ver);
                }
                else
                {
                    return("连接失败");
                }
            }
            else
            {
                return("连接失败");
            }

            return("连接成功");
        }
        //
        // GET: /ReadCard/

        public ActionResult Index()
        {
            st = 0;

            Int16 port = 1;
            int   baud = 9600;

            byte[] ver      = new byte[30];
            byte[] hard_ver = new byte[30];

            st    = IC.lib_ver(ver);
            icdev = IC.ic_init(port, baud);
            if (icdev > 0)
            {
                ViewBag.com = "打开串口成功!";
                byte[] status = new byte[5];
                st = IC.get_status(icdev, status);
                if (st != 0)
                {
                    ViewBag.com = "获取设备状态失败!";
                }
                st = IC.srd_ver(icdev, 18, hard_ver);
                if (st == 0)
                {
                    ViewBag.SoftVer = System.Text.Encoding.ASCII.GetString(ver);
                    ViewBag.HardVer = System.Text.Encoding.ASCII.GetString(hard_ver);
                }
                else
                {
                    ViewBag.com = "读取硬件版本号失败!";
                }
            }
            else
            {
                ViewBag.com = "打开串口失败!";
            }
            return(View());
        }
        public string VerifyData(SearchConditionView search)
        {
            byte[] key1   = new byte[20];
            byte[] key2   = new byte[20];
            byte[] ver    = new byte[30];
            byte[] status = new byte[5];
            int    i      = 0;

            st    = IC.lib_ver(ver);
            st    = IC.get_status(icdev, status);
            icdev = IC.ic_init(1, 9600);
            string lbResult;
            string skey = search.Condition1;

            if (skey == null)
            {
                lbResult = "请正确输入数据!";
                return(lbResult);
            }
            int keylen = skey.Length;

            if (keylen != 6)
            {
                lbResult = "请正确输入密码,密码长度不对!";
                return(lbResult);
            }

            for (i = 0; i < keylen; i++)
            {
                if (skey[i] >= '0' && skey[i] <= '9')
                {
                    continue;
                }
                if (skey[i] <= 'a' && skey[i] <= 'f')
                {
                    continue;
                }
                if (skey[i] <= 'A' && skey[i] <= 'F')
                {
                    continue;
                }
            }
            if (i != keylen)
            {
                lbResult = "密码必须为十六进制数!";
                return(lbResult);
            }

            key1 = System.Text.Encoding.ASCII.GetBytes(skey);
            IC.asc_hex(key1, key2, 6);
            st = IC4442.csc_4442(icdev, 3, key2);
            if (st == 0)
            {
                lbResult = "密码校验成功!";
            }
            else
            {
                lbResult = "密码校验失败!";
            }
            return(lbResult);
        }