Ejemplo n.º 1
0
        private void btnReadData_Click(object sender, System.EventArgs e)
        {
            int i = 0;

            byte[] data     = new byte[16];
            byte[] databuff = new byte[32];

            for (i = 0; i < 16; i++)
            {
                data[i] = 0;
            }
            for (i = 0; i < 32; i++)
            {
                databuff[i] = 0;
            }

            st = IC4442.srd_4442(icdev, 64, 16, data);
            if (st == 0)
            {
                st            = IC.hex_asc(data, databuff, 16);
                lbData.Text   = System.Text.Encoding.ASCII.GetString(databuff);
                lbResult.Text = "读数据成功!";
            }
            else
            {
                lbResult.Text = "读数据失败!";
            }
        }
Ejemplo n.º 2
0
        private void btnVerify_Click(object sender, System.EventArgs e)
        {
            byte[] key1   = new byte[20];
            byte[] key2   = new byte[20];
            int    i      = 0;
            string skey   = textKey.Text;
            int    keylen = textKey.TextLength;

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

            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.Text = "密码必须为十六进制数!";
                return;
            }

            key1 = Encoding.ASCII.GetBytes(skey);
            IC.asc_hex(key1, key2, 6);
            st = IC4442.csc_4442(icdev, 3, key2);
            if (st == 0)
            {
                lbResult.Text = "密码校验成功!";
            }
            else
            {
                lbResult.Text = "密码校验失败!";
            }
        }
Ejemplo n.º 3
0
        private void btnWriteData_Click(object sender, System.EventArgs e)
        {
            int i = 0;

            byte[] databuff = new byte[20];
            byte[] buff     = new byte[40];

            if (textData.TextLength != 32)
            {
                lbResult.Text = "请正确输入数据,数据长度必须为16字节!";
                return;
            }
            string data = textData.Text;

            for (i = 0; i < data.Length; i++)
            {
                if (data[i] >= '0' && data[i] <= '9')
                {
                    continue;
                }
                if (data[i] <= 'a' && data[i] <= 'f')
                {
                    continue;
                }
                if (data[i] <= 'A' && data[i] <= 'F')
                {
                    continue;
                }
            }
            if (i != data.Length)
            {
                lbResult.Text = "数据必须为十六进制数!";
                return;
            }

            buff = Encoding.ASCII.GetBytes(data);
            IC.asc_hex(buff, databuff, 32);
            st = IC4442.swr_4442(icdev, 64, 16, databuff);
            if (st == 0)
            {
                lbResult.Text = "写数据成功!";
            }
            else
            {
                lbResult.Text = "写数据失败!";
            }
        }