public Status_enum Inventory(byte ReaderID, ref byte[] UID, Antenna_enum ant) { if (UID.Length < UIDLEN) { return(Status_enum.PARAM_ERR); } try { InvReqFlg = true; Package package = new Package(CmdEnum.CMD_INVENTORY, ReaderID, ant); if (SendPackage(package)) { return(WaitResp(package.CMD, ref UID, ref tempbyte)); } else { return(Status_enum.SERIAL_CLOSED); } } finally { InvReqFlg = false; } }
public Package(CmdEnum cmd, byte id, Antenna_enum ant) { this.CMD = cmd; this.ReaderID = id; this.States = 0x00; this.Opcode = Opcode_enum.NON_ADDRESS_MODE; this.Ant = ant; this.DataLen = 0x00; this.BCC = 0x00; }
public void add(byte[] uid, Antenna_enum ant) { foreach (TagReadResult tmp in UidList) { if (tool.ByteCmp(tmp.UID, 0, uid, 0, 8) && (tmp.antenna == ant)) { return; } } UidList.Add(new TagReadResult(uid, ant)); }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
public TagReadResult(byte[] uid, Antenna_enum ant) { antenna = ant; Array.Copy(uid, UID, 8); }