예제 #1
0
        public static void embeddedRead(TagProtocol protocol, TagFilter filter, TagOp tagop)
        {
            TagReadData[]  tagReads = null;
            SimpleReadPlan plan     = new SimpleReadPlan(antennaList, protocol, filter, tagop, 1000);

            r.ParamSet("/reader/read/plan", plan);
            tagReads = r.Read(1000);
            // Print tag reads
            foreach (TagReadData tr in tagReads)
            {
                Console.WriteLine(tr.ToString());
                if (tr.isErrorData)
                {
                    // In case of error, show the error to user. Extract error code.
                    int errorCode = ByteConv.ToU16(tr.Data, 0);
                    Console.WriteLine("Embedded Tag operation failed. Error: " + ReaderCodeException.faultCodeToMessage(errorCode));
                }
                else
                {
                    if (tagop is Gen2.EMMicro.EM4325.GetSensorData)
                    {
                        if (tr.Data.Length > 0)
                        {
                            GetSensorDataResponse rData = new GetSensorDataResponse(tr.Data);
                            Console.WriteLine("Data:" + rData.ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("  Data:" + ByteFormat.ToHex(tr.Data, "", " "));
                    }
                }
            }
        }
예제 #2
0
        public static void parseGetSystemInfoResponse(byte[] systemInfo)
        {
            int readIndex = 0;
            // Extract 1 byte of Information Flags from response
            byte infoFlags = systemInfo[readIndex++];

            //Extract UID - 8 bytes for Iso15693
            int uidLength = 8;

            byte[] uid = new byte[uidLength];
            Array.Copy(systemInfo, readIndex, uid, 0, uidLength);
            Console.WriteLine("UID: " + ByteFormat.ToHex(uid));
            readIndex += uidLength;
            if (infoFlags == 0)
            {
                Console.WriteLine("No information flags are enabled");
            }
            else
            {
                // Checks Information flags are supported or not and then extracts respective fields information.
                if ((infoFlags & 0x0001) == 0x0001)
                {
                    Console.WriteLine("DSFID is supported and DSFID field is present in the response");
                    //Extract 1 byte of DSFID
                    byte dsfid = systemInfo[readIndex++];
                    Console.WriteLine("DSFID: " + dsfid.ToString());
                }
                if ((infoFlags & 0x0002) == 0x0002)
                {
                    Console.WriteLine("AFI is supported and AFI field is present in the response");
                    //Extract 1 byte of AFI
                    byte afi = systemInfo[readIndex++];
                    Console.WriteLine("AFI: " + afi.ToString());
                }
                if ((infoFlags & 0x0004) == 0x0004)
                {
                    Console.WriteLine("VICC memory size is supported and VICC field is present in the response");
                    //Extract 2 bytes of VICC information
                    UInt16 viccInfo      = ByteConv.ToU16(systemInfo, readIndex);
                    byte   maxBlockCount = (byte)(viccInfo & 0xFF);    // holds the number of blocks
                    Console.WriteLine("Max Block count: " + maxBlockCount);
                    byte blocksize = (byte)((viccInfo & 0x1F00) >> 8); // holds blocksize
                    Console.WriteLine("Block Size: " + blocksize);
                    readIndex += 2;
                }
                if ((infoFlags & 0x0008) == 0x0008)
                {
                    Console.WriteLine("IC reference is supported and IC reference is present in the response");
                    // Extract 1 byte of IC reference
                    byte icRef = systemInfo[readIndex++];
                    Console.WriteLine("IC Reference: " + icRef.ToString());
                }
            }
        }