示例#1
0
        protected InventoryScanInfo HandleInventoryScanFrame(byte[] frame)
        {
            InventoryScanInfo info       = new InventoryScanInfo(frame);
            ReturnMessage     returnCode = CheckFrame(info);

            if (returnCode != ReturnMessage.Success)
            {
                info.ReturnValue = returnCode;
                return(info);
            }
            int len = frame.Length - 5;

            byte[] cardData = new byte[len];
            Array.Copy(frame, 3, cardData, 0, len);
            List <InventoryScanInfo.CardInfo> cardSet = info.CardSet;
            int index = 0;

            while (index < len)
            {
                InventoryScanInfo.CardInfo cardInfo = new InventoryScanInfo.CardInfo();
                cardInfo.DSFID = cardData[index++]; //拷贝 DSFID
                Array.Copy(cardData, index, cardInfo.UID, 0, 8);
                index += 8;
                cardSet.Add(cardInfo);
            }
            info.ReturnValue = ReturnMessage.Success;
            return(info);
        }
示例#2
0
        /// <summary>
        /// 不带AFI的Inventory-scan。
        /// 新询查命令:在运行询查命令前,读写器会自动运行“Close RF”和“Open RF”。
        /// 这样,处于感应场内的符合协议的所有电子标签均能响应,读写器会把在
        /// InventoryScanTime溢出前得到的UID全部返回。
        /// 继续询查命令:读写器不会对感应场进行操作,只有新进入感应场的电子标签或
        /// 前面的询查命令没有得到UID的电子标签才会响应,读写器会把在
        /// InventoryScanTime溢出前得到的UID返回
        /// </summary>
        /// <param name="mode">0x06:新询查命令,0x02:继续询查命令</param>
        /// <returns></returns>
        public async Task <InventoryScanInfo> InventoryScanWithoutAFIAsync(InventoryScanWithoutAFIMode mode)
        {
            byte[] frame = CreateInventoryScanWithoutAFIFrame(mode);
            CommunicationReturnInfo cri = await com.SendAsync(frame);

            if (cri.ReturnValue != ReturnMessage.Success)
            {
                InventoryScanInfo isi = new InventoryScanInfo();
                isi.SendByte         = frame;
                isi.ReturnValue      = cri.ReturnValue;
                isi.ExceptionMessage = cri.ExceptionMessage;
                return(isi);
            }

            InventoryScanInfo info = HandleInventoryScanFrame(cri.RecvByte);

            info.SendByte = frame;
            return(info);
        }