Beispiel #1
0
        protected ReadSingleBlockInfo HandleReadSingleBlockFrame(byte[] frame)
        {
            ReadSingleBlockInfo info;

            if (frame.Length == 0x0A)
            {
                info = new ReadSingleBlockInfo(I15693BlockLen.Four, frame);
            }
            else
            {
                info = new ReadSingleBlockInfo(I15693BlockLen.Eight, frame);
            }
            ReturnMessage returnCode = CheckFrame(info);

            if (returnCode != ReturnMessage.Success)
            {
                info.ReturnValue = returnCode;
                return(info);
            }

            info.BlockSecurityStatus = frame[3]; //块安全状态编码
            if (frame.Length == 0x0A)
            {
                Array.Copy(frame, 4, info.BlockData, 0, 4); //拷贝数据
            }
            else
            {
                Array.Copy(frame, 4, info.BlockData, 0, 8);
            }
            info.ReturnValue = ReturnMessage.Success;
            return(info);
        }
Beispiel #2
0
        /// <summary>
        /// 上位机发送该命令读取电子标签中指定块的数据(4或8个字节)和安全状态信息。
        /// 该命令可以在address mode和select mode下运行。
        /// </summary>
        /// <param name="blockLen">卡的数据块所占空间的字节数,4或8</param>
        /// <param name="blockNum">绝对块号</param>
        /// <returns></returns>
        public async Task <ReadSingleBlockInfo> ReadSingleBlockAsync(I15693BlockLen blockLen, byte blockNum)
        {
            byte[] frame = CreateReadSingleBlockFrame(blockLen, blockNum);
            CommunicationReturnInfo cri = await com.SendAsync(frame);

            if (cri.ReturnValue != ReturnMessage.Success)
            {
                ReadSingleBlockInfo ib = new ReadSingleBlockInfo();
                ib.SendByte         = frame;
                ib.ReturnValue      = cri.ReturnValue;
                ib.ExceptionMessage = cri.ExceptionMessage;
                return(ib);
            }
            ReadSingleBlockInfo info = HandleReadSingleBlockFrame(cri.RecvByte);

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