Exemplo n.º 1
0
        //复位标签
        public Status_enum ResetTag(byte ReaderID, Opcode_enum Opcode, byte[] UID)
        {
            byte[]  temp    = null;
            Package package = new Package(CmdEnum.CMD_RESET_TO_READY, ReaderID);

            if (SendPackage(package))
            {
                return(WaitResp(package.CMD, ref temp, ref tempbyte));
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Exemplo n.º 2
0
        //获取标签系统信息
        public Status_enum GetTagInfo(byte ReaderID, Opcode_enum Opcode, byte[] UID_I, ref byte InformationFlag,
                                      ref byte[] UID_O, ref byte DSFID, ref byte AFI, ref byte BlockCnt, ref byte BlockSize, ref byte ICReference)
        {
            byte[] temp = new byte[14];

            if (UID_O.Length < UIDLEN)
            {
                return(Status_enum.PARAM_ERR);
            }

            Package package = new Package(CmdEnum.CMD_GET_VICC_INFO, ReaderID);

            if ((UID_I != null) && (UID_I.Length >= 8))
            {
                package.Opcode = Opcode;
            }
            else
            {
                package.Opcode = Opcode_enum.NON_ADDRESS_MODE;
            }
            if (package.Opcode == Opcode_enum.ADDRESS_MODE)
            {
                Array.Copy(UID_I, 0, package.Datas, package.DataLen, 8);
                package.DataLen += 8;
                package.BCC      = tool.GetBCC(package.Datas, 0, package.DataLen);
            }
            if (SendPackage(package))
            {
                Status_enum status = WaitResp(package.CMD, ref temp, ref tempbyte);
                if (status == Status_enum.SUCCESS)
                {
                    int pos = 0;
                    InformationFlag = temp[pos++];
                    for (int i = 0; i < UIDLEN; i++)
                    {
                        UID_O[i] = temp[pos++];
                    }
                    DSFID       = temp[pos++];
                    AFI         = temp[pos++];
                    BlockCnt    = temp[pos++];
                    BlockSize   = temp[pos++];
                    ICReference = temp[pos++];
                }
                return(status);
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Exemplo n.º 3
0
        public Status_enum GetTagInfo(byte ReaderID, Opcode_enum Opcode, byte[] UID, ref TagInfo info, Antenna_enum ant)
        {
            byte[] temp = new byte[14];

            Package package = new Package(CmdEnum.CMD_GET_VICC_INFO, ReaderID, ant);

            if ((UID != null) && (UID.Length >= 8))
            {
                package.Opcode = Opcode;
            }
            else
            {
                package.Opcode = Opcode_enum.NON_ADDRESS_MODE;
            }
            if (package.Opcode == Opcode_enum.ADDRESS_MODE)
            {
                Array.Copy(UID, 0, package.Datas, package.DataLen, 8);
                package.DataLen += 8;
                package.BCC      = tool.GetBCC(package.Datas, 0, package.DataLen);
            }
            if (SendPackage(package))
            {
                Status_enum status = WaitResp(package.CMD, ref temp, ref tempbyte);
                if (status == Status_enum.SUCCESS)
                {
                    if (info == null)
                    {
                        info = new TagInfo();
                    }
                    int pos = 0;
                    info.InformationFlag = temp[pos++];
                    for (int i = 0; i < UIDLEN; i++)
                    {
                        info.UID[i] = temp[pos++];
                    }
                    info.DSFID        = temp[pos++];
                    info.AFI          = temp[pos++];
                    info.BlockCnt     = temp[pos++];
                    info.BlockSize    = temp[pos++];
                    info.ICrefcerence = temp[pos++];
                }
                return(status);
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Exemplo n.º 4
0
        public Status_enum ReadMBlock(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte StartBlock, byte BlockCnt, ref byte[] datas, ref byte len, Antenna_enum ant)
        {
            byte[]  data    = new byte[] { StartBlock, BlockCnt };
            Package package = new Package(CmdEnum.CMD_READ_MBLOCKS, Opcode, UID, ReaderID, data, 0, (byte)data.Length);

            package.Ant = ant;
            if (SendPackage(package))
            {
                //接收
                return(WaitResp(package.CMD, ref datas, ref len));
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Exemplo n.º 5
0
        public Status_enum LockSBlock(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte Block, Antenna_enum ant)
        {
            byte[] temp = null;

            byte[]  data    = new byte[] { Block };
            Package package = new Package(CmdEnum.CMD_LOCK_SBLOCK, Opcode, UID, ReaderID, data, 0, (byte)data.Length);

            package.Ant = ant;

            if (SendPackage(package))
            {
                //接收
                return(WaitResp(package.CMD, ref temp, ref tempbyte));
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Exemplo n.º 6
0
        public Status_enum WriteMBlock(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte StartBlock, byte BlockCnt, int BlockSize, byte[] BlockDatas, Antenna_enum ant)
        {
            byte[] temp = null;

            //单块大小为4字节或8字节
            if (((BlockSize != 4) && (BlockSize != 8)) ||
                (BlockDatas.Length < BlockCnt * BlockSize) ||
                (BlockCnt > 8))
            {
                return(Status_enum.PARAM_ERR);
            }

            Package package = new Package(CmdEnum.CMD_WRITE_MBLOCK, ReaderID, ant);

            if ((UID != null) && (UID.Length >= 8))
            {
                package.Opcode = Opcode;
            }
            else
            {
                package.Opcode = Opcode_enum.NON_ADDRESS_MODE;
            }
            if (package.Opcode == Opcode_enum.ADDRESS_MODE)
            {
                Array.Copy(UID, 0, package.Datas, package.DataLen, 8);
                package.DataLen += 8;
            }
            package.Datas[package.DataLen++] = StartBlock;
            package.Datas[package.DataLen++] = BlockCnt;
            Array.Copy(BlockDatas, 0, package.Datas, package.DataLen, BlockCnt * BlockSize);
            package.DataLen += (byte)(BlockCnt * BlockSize);
            package.BCC      = tool.GetBCC(package.Datas, 0, package.DataLen);
            if (SendPackage(package))
            {
                //接收
                return(WaitResp(package.CMD, ref temp, ref tempbyte));
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Exemplo n.º 7
0
        public Status_enum GetTagSecurity(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte StartBlock, byte BlockCnt, ref byte[] TagSecurity, Antenna_enum ant)
        {
            if (TagSecurity.Length < BlockCnt)
            {
                return(Status_enum.PARAM_ERR);
            }

            byte[]  data    = new byte[] { StartBlock, BlockCnt };
            Package package = new Package(CmdEnum.CMD_GET_SECURITY, Opcode, UID, ReaderID, data, 0, (byte)data.Length);

            package.Ant = ant;
            if (SendPackage(package))
            {
                //接收
                return(WaitResp(package.CMD, ref TagSecurity, ref tempbyte));
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Exemplo n.º 8
0
        public Status_enum ReadSBlock(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte Block, ref byte[] BlockDatas, ref byte len, Antenna_enum ant)
        {
            /*            if (BlockDatas.Length < 4)
             *          {
             *              return Status_enum.PARAM_ERR;
             *          }
             */
            byte[]  data    = new byte[] { Block };
            Package package = new Package(CmdEnum.CMD_READ_SBLOCK, Opcode, UID, ReaderID, data, 0, (byte)data.Length);

            package.Ant = ant;

            if (SendPackage(package))
            {
                //接收
                return(WaitResp(package.CMD, ref BlockDatas, ref len));
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Exemplo n.º 9
0
 //获取标签块安全状态
 public Status_enum GetTagSecurity(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte StartBlock, byte BlockCnt, ref byte[] TagSecurity)
 {
     return(GetTagSecurity(ReaderID, Opcode, UID, StartBlock, BlockCnt, ref TagSecurity, Antenna_enum.ANT_1));
 }
Exemplo n.º 10
0
 //写多块
 public Status_enum WriteMBlock(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte StartBlock, byte BlockCnt, int BlockSize, byte[] BlockDatas)
 {
     return(WriteMBlock(ReaderID, Opcode, UID, StartBlock, BlockCnt, BlockSize, BlockDatas, Antenna_enum.ANT_1));
 }
Exemplo n.º 11
0
 //读多块
 public Status_enum ReadMBlock(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte StartBlock, byte BlockCnt, ref byte[] datas, ref byte len)
 {
     return(ReadMBlock(ReaderID, Opcode, UID, StartBlock, BlockCnt, ref datas, ref len, Antenna_enum.ANT_1));
 }
Exemplo n.º 12
0
 //锁单块
 public Status_enum LockSBlock(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte Block)
 {
     return(LockSBlock(ReaderID, Opcode, UID, Block, Antenna_enum.ANT_1));
 }
Exemplo n.º 13
0
 //写单块
 public Status_enum WriteSBlock(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte Block, int len, byte[] BlockDatas)
 {
     return(WriteSBlock(ReaderID, Opcode, UID, Block, len, BlockDatas, Antenna_enum.ANT_1));
 }
Exemplo n.º 14
0
 //读单块
 public Status_enum ReadSBlock(byte ReaderID, Opcode_enum Opcode, byte[] UID, byte Block, ref byte[] BlockDatas, ref byte len)
 {
     return(ReadSBlock(ReaderID, Opcode, UID, Block, ref BlockDatas, ref len, Antenna_enum.ANT_1));
 }