C# AT指令 连接RFID ISO15693

使用SerialPortHelper

C# 串口通讯 SerialPortHelper_天道酬勤~的博客-CSDN博客




 

发送:04 01 DC 1E  查看列表

发送:0D 01 D8 + UID + 校验值:写DSFID;

校验值计算:

        public string Math_jiaoyanzhi(string str_code)
        {
            
            str_code = str_code.ToLower();
            str_code = str_code.Replace(" ", "");
            write_log("str_code:" + str_code);
            int total_d=0;
            string relue_str = "";
            for (int i =0;i< str_code.Length; i += 2)
            {
                relue_str += str_code.Substring(i, 2)+" ";
                total_d += Convert.ToInt32(str_code.Substring(i, 2), 16);

            }
            string str_total_d = total_d.ToString("X");
            write_log("str_total_d:"+str_total_d);
            str_total_d = str_total_d.Substring(str_total_d.Length - 2);
            write_log("conevt str_total_d:" + str_total_d);
            sbyte d = Convert.ToSByte(str_total_d, 16);
            d = (sbyte)~d;
            relue_str += d.ToString("x");

            write_log("relue_str:" + relue_str);
            return relue_str.ToUpper();
        }

你可能感兴趣的:(C#,c#,开发语言)