Esempio n. 1
0
        public void Add_AccessSpec()
        {
            MSG_ERROR_MESSAGE  msg_err;
            MSG_ADD_ACCESSSPEC msg = new MSG_ADD_ACCESSSPEC();

            msg.AccessSpec = new PARAM_AccessSpec();

            /////////////////////////////////////////////////
            // AccessSpec
            /////////////////////////////////////////////////
            // AccessSpecID should be set to a unique identifier.
            msg.AccessSpec.AccessSpecID = 456;
            msg.AccessSpec.AntennaID    = 0;
            // We're writing to a Gen2 tag
            msg.AccessSpec.ProtocolID = ENUM_AirProtocols.EPCGlobalClass1Gen2;
            // AccessSpecs must be disabled when you add them.
            msg.AccessSpec.CurrentState = ENUM_AccessSpecState.Disabled;
            msg.AccessSpec.ROSpecID     = 0;
            // Setup the triggers
            msg.AccessSpec.AccessSpecStopTrigger =
                new PARAM_AccessSpecStopTrigger();
            msg.AccessSpec.AccessSpecStopTrigger.AccessSpecStopTrigger =
                ENUM_AccessSpecStopTriggerType.Null;
            // OperationCountValue indicate the number of times this Spec is
            // executed before it is deleted. If set to 0, this is equivalent
            // to no stop trigger defined.
            msg.AccessSpec.AccessSpecStopTrigger.OperationCountValue = 0;

            /////////////////////////////////////////////////
            // AccessCommand
            //
            // Define which tags we want to write to.
            /////////////////////////////////////////////////
            msg.AccessSpec.AccessCommand = new PARAM_AccessCommand();
            msg.AccessSpec.AccessCommand.AirProtocolTagSpec =
                new UNION_AirProtocolTagSpec();
            PARAM_C1G2TagSpec tagSpec = new PARAM_C1G2TagSpec();

            // Specify the target tag. Which tag do we want to write to?
            tagSpec.C1G2TargetTag          = new PARAM_C1G2TargetTag[1];
            tagSpec.C1G2TargetTag[0]       = new PARAM_C1G2TargetTag();
            tagSpec.C1G2TargetTag[0].Match = true;
            // We'll use the tag's EPC to determine if this is the label we want.
            // Set the memory bank to 1 (The EPC memory bank on a Monza 4 tag).
            tagSpec.C1G2TargetTag[0].MB = new TwoBits(1);
            // The first (msb) bit location of the specified memory
            // bank against which to compare the TagMask.
            // We'll set it to 0x20, to skip the protocol
            // control bits and CRC.
            tagSpec.C1G2TargetTag[0].Pointer = 0x20;
            tagSpec.C1G2TargetTag[0].TagMask =
                LLRPBitArray.FromHexString("FFFFFFFFFFFFFFFFFFFFFFFF");
            tagSpec.C1G2TargetTag[0].TagData =
                LLRPBitArray.FromHexString("300833B2DDD9014000000000");
            msg.AccessSpec.AccessCommand.AirProtocolTagSpec.Add(tagSpec);

            /////////////////////////////////////////////////
            // AccessCommandOpSpec
            //
            // Define the data we want to write.
            /////////////////////////////////////////////////
            msg.AccessSpec.AccessCommand.AccessCommandOpSpec =
                new UNION_AccessCommandOpSpec();
            PARAM_C1G2Write wr = new PARAM_C1G2Write();

            wr.AccessPassword = 0;
            // Bank 3 is user memory on a Monza 4 tag.
            wr.MB = new TwoBits(3);
            // OpSpecID should be set to a unique identifier.
            wr.OpSpecID = 111;
            // Write to the base of user memory.
            wr.WordPointer = 0x00;
            // Data to be written.
            wr.WriteData = UInt16Array.FromHexString("0123456789ABCDEF");
            msg.AccessSpec.AccessCommand.AccessCommandOpSpec.Add(wr);

            /////////////////////////////////////////////////
            // AccessReportSpec
            //
            // Define when we want to receive AccessReports
            /////////////////////////////////////////////////
            msg.AccessSpec.AccessReportSpec = new PARAM_AccessReportSpec();
            msg.AccessSpec.AccessReportSpec.AccessReportTrigger =
                ENUM_AccessReportTriggerType.End_Of_AccessSpec;

            // Send the message and check the reply
            MSG_ADD_ACCESSSPEC_RESPONSE rsp =
                reader.ADD_ACCESSSPEC(msg, out msg_err, 2000);

            if (rsp != null)
            {
                // Success
                Console.WriteLine(rsp.ToString());
            }
            else if (msg_err != null)
            {
                // Error
                Console.WriteLine(msg_err.ToString());
            }
            else
            {
                // Timeout
                Console.WriteLine("Timeout Error.");
            }
        }
Esempio n. 2
0
        private bool ADD_ACCESSSPEC(string tagdata, int type)
        {
            MSG_ADD_ACCESSSPEC msg = new MSG_ADD_ACCESSSPEC();

            msg.AccessSpec = new PARAM_AccessSpec();

            msg.AccessSpec.AccessSpecID = 1001;
            msg.AccessSpec.AntennaID    = 1;
            msg.AccessSpec.ProtocolID   = ENUM_AirProtocols.EPCGlobalClass1Gen2;
            msg.AccessSpec.CurrentState = ENUM_AccessSpecState.Disabled;
            msg.AccessSpec.ROSpecID     = 123;

            //define trigger
            msg.AccessSpec.AccessSpecStopTrigger = new PARAM_AccessSpecStopTrigger();
            msg.AccessSpec.AccessSpecStopTrigger.AccessSpecStopTrigger = ENUM_AccessSpecStopTriggerType.Operation_Count;
            msg.AccessSpec.AccessSpecStopTrigger.OperationCountValue   = 100;

            //define access command

            //define air protocol spec
            msg.AccessSpec.AccessCommand = new PARAM_AccessCommand();
            msg.AccessSpec.AccessCommand.AirProtocolTagSpec = new UNION_AirProtocolTagSpec();

            PARAM_C1G2TagSpec tagSpec = new PARAM_C1G2TagSpec();

            tagSpec.C1G2TargetTag            = new PARAM_C1G2TargetTag[1];
            tagSpec.C1G2TargetTag[0]         = new PARAM_C1G2TargetTag();
            tagSpec.C1G2TargetTag[0].Match   = false; //change to "true" if you want to the following parameters take effect.
            tagSpec.C1G2TargetTag[0].MB      = new TwoBits(1);
            tagSpec.C1G2TargetTag[0].Pointer = 0x20;
            tagSpec.C1G2TargetTag[0].TagData = LLRPBitArray.FromString("1111");
            tagSpec.C1G2TargetTag[0].TagMask = LLRPBitArray.FromBinString("1111111111111111");

            msg.AccessSpec.AccessCommand.AirProtocolTagSpec.Add(tagSpec);

            //define access spec
            msg.AccessSpec.AccessCommand.AccessCommandOpSpec = new UNION_AccessCommandOpSpec();

            PARAM_C1G2Write wr = new PARAM_C1G2Write();

            wr.AccessPassword = 0;
            wr.MB             = new TwoBits(1);
            wr.OpSpecID       = 111;
            wr.WordPointer    = 2;
            //Data to be written.
            wr.WriteData = UInt16Array.FromHexString(tagdata);
            msg.AccessSpec.AccessCommand.AccessCommandOpSpec.Add(wr);

            msg.AccessSpec.AccessReportSpec = new PARAM_AccessReportSpec();
            msg.AccessSpec.AccessReportSpec.AccessReportTrigger = ENUM_AccessReportTriggerType.End_Of_AccessSpec;

            MSG_ADD_ACCESSSPEC_RESPONSE rsp = reader.ADD_ACCESSSPEC(msg, out msg_err, 12000);

            if (rsp != null)
            {
                //return rsp.ToString();
                return(true);
            }
            else if (msg_err != null)
            {
                //return msg_err.ToString();
                return(false);
            }
            else
            {
                //return "Command time out!";
                return(false);
            }
        }