コード例 #1
0
        private static SimpleReadPlan configureM3ePersistentSettings(Reader r, int[] antennaList)
        {
            try
            {
                //baudrate
                r.ParamSet("/reader/baudRate", 115200);
                //Protocol
                TagProtocol protocol = TagProtocol.ISO14443A;
                r.ParamSet("/reader/tagop/protocol", protocol);
                //enable read filter
                r.ParamSet("/reader/tagReadData/enableReadFilter", true);

                // Embedded tag operation

                /* Uncomment the following line if want to enable embedded read with autonomous operation.
                 * Add tagop object op in simple read plan constructor.
                 * Add filter object epcFilter in simple read plan constructor.
                 */
                //MemoryType type = MemoryType.BLOCK_MEMORY;
                //int address = 0;
                //byte length = 1;
                //ReadMemory tagOp = new ReadMemory(type, address, length);
                //Select_UID filter = new Select_UID(32, new byte[] { 0x11, 0x22, 0x33, 0x44 });

                GpiPinTrigger gpiTrigger = null;
                if ((autoReadType != null) && (autoReadType == "ReadOnGPI"))
                {
                    gpiTrigger        = new GpiPinTrigger();
                    gpiTrigger.enable = true;
                    //set the gpi pin to read on
                    r.ParamSet("/reader/read/trigger/gpi", new int[] { trigTypeNum });
                }
                SimpleReadPlan srp = new SimpleReadPlan(antennaList, protocol, null, null, 1000);
                if ((autoReadType != null) && (autoReadType == "ReadOnGPI"))
                {
                    srp.ReadTrigger = gpiTrigger;
                }
                return(srp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // Program setup
            if (1 > args.Length)
            {
                Usage();
            }
            int[] antennaList = null;
            for (int nextarg = 1; nextarg < args.Length; nextarg++)
            {
                string arg = args[nextarg];
                if (arg.Equals("--ant"))
                {
                    if (null != antennaList)
                    {
                        Console.WriteLine("Duplicate argument: --ant specified more than once");
                        Usage();
                    }
                    antennaList = ParseAntennaList(args, nextarg);
                    nextarg++;
                }
                else
                {
                    Console.WriteLine("Argument {0}:\"{1}\" is not recognized", nextarg, arg);
                    Usage();
                }
            }

            try
            {
                // Create Reader object, connecting to physical device.
                // Wrap reader in a "using" block to get automaticq
                // reader shutdown (using IDisposable interface).
                using (Reader r = Reader.Create(args[0]))
                {
                    //Uncomment this line to add default transport listener.
                    //r.Transport += r.SimpleTransportListener;

                    r.Connect();
                    string model = (string)r.ParamGet("/reader/version/model");
                    if ("M6e".Equals(model) || "M6e PRC".Equals(model) || "M6e JIC".Equals(model) || "M6e Micro".Equals(model) ||
                        "M6e Nano".Equals(model) || "M6e Micro USB".Equals(model) || "M6e Micro USBPro".Equals(model))
                    {
                        if (Reader.Region.UNSPEC == (Reader.Region)r.ParamGet("/reader/region/id"))
                        {
                            Reader.Region[] supportedRegions = (Reader.Region[])r.ParamGet("/reader/region/supportedRegions");
                            if (supportedRegions.Length < 1)
                            {
                                throw new FAULT_INVALID_REGION_Exception();
                            }
                            r.ParamSet("/reader/region/id", supportedRegions[0]);
                        }
                        if ((model.Equals("M6e Micro") || model.Equals("M6e Nano")) && antennaList == null)
                        {
                            Console.WriteLine("Module doesn't has antenna detection support please provide antenna list");
                            Usage();
                        }
                        //Uncomment the following line to revert the module settings to factory defaluts
                        //r.ParamSet("/reader/userConfig", new SerialReader.UserConfigOp(SerialReader.UserConfigOperation.CLEAR));
                        //Console.WriteLine("User profile set option:reset all configuration");

                        //Uncomment this if readerstats need to be included
                        //r.ParamSet("/reader/stats/enable", Reader.Stat.StatsFlag.TEMPERATURE);

                        /* Uncomment the following lines if want to enable embedded read and filter with autonomous operation.
                         * Add tagop object readtagOp and filter object epcFilter in simple read plan constructor.
                         */

                        //Gen2.ReadData readtagOp = new Gen2.ReadData(Gen2.Bank.RESERVED, 2, 2);
                        //Gen2.TagData epcFilter = new Gen2.TagData(new byte[] { 0x11,0x22,0x33,0x44,0x55,0x66,0x77,
                        //0x88,0x99,0x00,0x99,0x99});

                        int[] gpiPin = new int[1];
                        gpiPin[0] = 1;
                        r.ParamSet("/reader/read/trigger/gpi", gpiPin);
                        GpiPinTrigger gpiPinTrigger = new GpiPinTrigger();
                        gpiPinTrigger.enable = true;
                        SimpleReadPlan srp = new SimpleReadPlan(antennaList, TagProtocol.GEN2, null, null, 1000);

                        //To disable autonomous read make enableAutonomousRead flag to false and do SAVEWITHRREADPLAN
                        srp.enableAutonomousRead = true;
                        srp.ReadTrigger          = gpiPinTrigger;

                        r.ParamSet("/reader/read/plan", srp);
                        r.ParamSet("/reader/userConfig", new SerialReader.UserConfigOp(SerialReader.UserConfigOperation.SAVEWITHREADPLAN));
                        Console.WriteLine("User profile set option:save all configuration with read plan");

                        r.ParamSet("/reader/userConfig", new SerialReader.UserConfigOp(SerialReader.UserConfigOperation.RESTORE));
                        Console.WriteLine("User profile set option:restore all configuration");

                        #region Create and add listeners

                        // Create and add tag listener
                        r.TagRead += delegate(Object sender, TagReadDataEventArgs e)
                        {
                            Console.WriteLine("Background read: " + e.TagReadData);
                            if (0 < e.TagReadData.Data.Length)
                            {
                                Console.WriteLine("  Data:" + ByteFormat.ToHex(e.TagReadData.Data, "", " "));
                            }
                        };

                        // Add reader stats listener
                        r.StatsListener += r_StatsListener;

                        #endregion Create and add listeners

                        r.ReceiveAutonomousReading();
                        Thread.Sleep(5000);
                    }
                    else
                    {
                        Console.WriteLine("Error: This codelet works only on M6e variants");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
コード例 #3
0
        private static SimpleReadPlan configureUHFPersistentSettings(Reader r, string model, int[] antennaList)
        {
            // baudrate
            r.ParamSet("/reader/baudRate", 115200);

            // Region
            Reader.Region[] supportRegion = (Reader.Region[])r.ParamGet("/reader/region/supportedRegions");
            if (supportRegion.Length < 1)
            {
                throw new Exception("Reader doesn't support any regions");
            }
            else
            {
                r.ParamSet("/reader/region/id", supportRegion[0]);
            }

            // Protocol
            TagProtocol protocol = TagProtocol.GEN2;

            r.ParamSet("/reader/tagop/protocol", protocol);

            // Antenna to search on
            r.ParamSet("/reader/tagop/antenna", antennaList[0]);

            // Duty cycle ->Async On time, Async off time
            r.ParamSet("/reader/read/asyncOnTime", 1000);
            r.ParamSet("/reader/read/asyncOffTime", 0);

            // Gen2 setting
            r.ParamSet("/reader/gen2/BLF", Gen2.LinkFrequency.LINK250KHZ);
            r.ParamSet("/reader/gen2/tari", Gen2.Tari.TARI_25US);
            r.ParamSet("/reader/gen2/target", Gen2.Target.A);
            r.ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.M2);
            r.ParamSet("/reader/gen2/session", Gen2.Session.S0);
            r.ParamSet("/reader/gen2/q", new Gen2.DynamicQ());

            //RF Power settings
            r.ParamSet("/reader/radio/readPower", 2000);
            r.ParamSet("/reader/radio/writePower", 2000);

            // Hop Table
            int[] hopTable = (int[])r.ParamGet("/reader/region/hopTable");
            r.ParamSet("/reader/region/hopTable", hopTable);

            int hopTimeValue = (int)r.ParamGet("/reader/region/hopTime");

            r.ParamSet("/reader/region/hopTime", hopTimeValue);

            //For Open region, dwell time, minimum frequency, quantization step can also be configured persistently
            if (Reader.Region.OPEN == (Reader.Region)r.ParamGet("/reader/region/id"))
            {
                //Set dwell time enable before stting dwell time
                r.ParamSet("/reader/region/dwellTime/enable", true);
                //set quantization step
                r.ParamSet("/reader/region/quantizationStep", 25000);

                //set dwell time
                r.ParamSet("/reader/region/dwellTime", 250);

                //set minimum frequency
                r.ParamSet("/reader/region/minimumFrequency", 859000);
            }

            // Embedded tag operation

            /* Uncomment the following line if want to enable embedded read with autonomous operation.
             * Add tagop object op in simple read plan constructor.
             * Add filter object epcFilter in simple read plan constructor.
             */
            //Gen2.ReadData readtagOp = new Gen2.ReadData(Gen2.Bank.RESERVED, 2, 2);
            //Gen2.TagData epcFilter = new Gen2.TagData(new byte[] { 0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0x00,0x99,0x99});

            GpiPinTrigger gpiTrigger = null;

            if ((autoReadType != null) && (autoReadType == "ReadOnGPI"))
            {
                gpiTrigger = new GpiPinTrigger();
                //Gpi trigger option not there for M6e Micro USB
                if (!("M6e Micro USB".Equals(model)))
                {
                    gpiTrigger.enable = true;
                    //set the gpi pin to read on
                    r.ParamSet("/reader/read/trigger/gpi", new int[] { trigTypeNum });
                }
            }
            SimpleReadPlan srp = new SimpleReadPlan(antennaList, protocol, null, null, 1000);

            if ((autoReadType != null) && autoReadType == "ReadOnGPI")
            {
                if (!("M6e Micro USB".Equals(model)))
                {
                    srp.ReadTrigger = gpiTrigger;
                }
            }
            return(srp);
        }