Card.HuaQing.FormatGasCard C# (CSharp) Метод

FormatGasCard() публичный Метод

public FormatGasCard ( Int16 com, Int32 baud, string kmm, string kh, string dqdm ) : int
com System.Int16
baud System.Int32
kmm string
kh string
dqdm string
Результат int
        public int FormatGasCard(Int16 com,          //串口号,从0开始
           Int32 baud,         //波特率
           string kmm,         //卡密码,写卡后返回新密码
           string kh,          //卡号
           string dqdm)
        {
            int icdev = ic_init(com, baud);
            byte[] useridasc = new byte[20];
            byte[] useridhex = new byte[20];
            //读卡号
            //读0xA1开始7个位置 用户编号为14位
            string UserID = "";
            Log.Debug("清卡开始:");
            Int16 str = srd_4442(icdev, 0xA1, 7, useridhex);
            if (str == 0)
            {
                str = hex_asc(useridhex, useridasc, 16);
                UserID = Encoding.ASCII.GetString(useridasc, 0, 14);        //读出卡号 (用户编号)14位  ok

            }
            int p1 = int.Parse(UserID.Substring(0, 4)) + int.Parse(UserID.Substring(4, 4));
            int p2 = int.Parse(UserID.Substring(8, 4)) + int.Parse(UserID.Substring(12, 2));
            int p3 = int.Parse(UserID.Substring(1, 4)) + int.Parse(UserID.Substring(9, 4));
            string ps = p1.ToString() + p2.ToString() + p3.ToString();
            Int32 X = Int32.Parse(ps);
            byte[] passwd1 = new byte[3];
            int x111 = X / 1000;
            int x211 = x111 / 256;
            int x311 = x211 / 256;
            int x411 = x311 % 256;
            passwd1[0] = byte.Parse(x411.ToString());
            int x511 = X / 1000;
            int x611 = x511 / 256;
            int x711 = x611 % 256;
            passwd1[1] = Byte.Parse(x711.ToString());
            int x811 = X / 1000;
            int x911 = x811 % 256;
            passwd1[2] = Byte.Parse(x911.ToString());
            //  byte[] passhex = new byte[3];
            // int aaa = asc_hex(passwd1, passhex, 3);
            int z = 0;
            //    csc_4442(icdev, 3, passwd);
            ////修改密码
            z = csc_4442(icdev, 3, passwd1);
           byte[] passwd = new byte[3] { 0xff, 0xff, 0xff };
            z = wsc_4442(icdev, 3, passwd);
            //清卡
           byte[] data_buffer = new byte[0xe0];
           for (int iii = 0; iii < data_buffer.Length; iii++)
           {
               data_buffer[iii] = 0xff;
           }
          z= swr_4442(icdev, 0x20, 0xe0, data_buffer);
          ic_exit(icdev);
            return z;
        }