Beispiel #1
0
        private static void ReadLevel3Helper(Reader rdr, ArgParser pargs, ReadLevel3Type type)
        {
            SerialReader sr = (SerialReader)rdr;
            string[] args = pargs.commandArgs;
            int timeout = 500;
            if (0 < args.Length)
            {
                timeout = Int32.Parse(args[0], System.Globalization.NumberStyles.Any);
            }

            Level3GetTagFunc gettags = null;
            switch (type)
            {
                default:
                    throw new NotSupportedException("Don't yet support ReadLevel3Type." + type.ToString());
                case ReadLevel3Type.WITHMETADATA:
                case ReadLevel3Type.BYCOUNT:
                case ReadLevel3Type.BYCOUNT496:
                    gettags = delegate()
                    {
                        bool epc496 = type == ReadLevel3Type.BYCOUNT496;
                        sr.CmdSetReaderConfiguration(SerialReader.Configuration.EXTENDED_EPC, epc496);
                        UInt16 maxrecspermsg = (UInt16)(240 / (epc496 ? 68 : 18));

                        while (true)
                        {
                            UInt16 bufcount = sr.CmdGetTagsRemaining()[0];
                            if (bufcount <= 0) { break; }
                            bufcount = Math.Min((UInt16)bufcount, maxrecspermsg);

                            if (ReadLevel3Type.WITHMETADATA == type)
                            {
                                TagReadData[] reads = sr.CmdGetTagBuffer(SerialReader.TagMetadataFlag.ALL, false, sr.CmdGetProtocol());
                                PrintTagReads(reads);
                            }
                            else
                            {
                                TagData[] tags = sr.CmdGetTagBuffer(bufcount, epc496, sr.CmdGetProtocol());
                                PrintTagDatas(tags);
                            }
                        }
                    };
                    break;
                case ReadLevel3Type.BYINDEX:
                case ReadLevel3Type.BYINDEX496:
                    gettags = delegate()
                    {
                        bool epc496 = type == ReadLevel3Type.BYINDEX496;
                        sr.CmdSetReaderConfiguration(SerialReader.Configuration.EXTENDED_EPC, epc496);
                        UInt16 maxrecspermsg = (UInt16)(240 / (epc496 ? 68 : 18));

                        UInt16 bufcount = sr.CmdGetTagsRemaining()[0];
                        if (bufcount <= 0) { return; }

                        UInt16 start = 0;
                        UInt16 end = bufcount;
                        while (start < end)
                        {
                            UInt16 subend = end;
                            UInt16 subcount = (UInt16)(subend - start);
                            subcount = Math.Min((UInt16)subcount, maxrecspermsg);
                            subend = (UInt16)(start + subcount);

                            TagData[] tags = sr.CmdGetTagBuffer(start, subend, epc496, sr.CmdGetProtocol());
                            PrintTagDatas(tags);
                            start += (UInt16)tags.Length;
                        }
                    };
                    break;
            }

            sr.CmdClearTagBuffer();
            sr.CmdReadTagMultiple((ushort)timeout, SerialReader.AntennaSelection.CONFIGURED_LIST, null, TagProtocol.NONE);
            gettags();
        }
Beispiel #2
0
 private static Command MakeReadLevel3Command(string name, string description, ReadLevel3Type readtype)
 {
     return new Command(
         delegate(Reader rdr, ArgParser pargs) { ReadLevel3Helper(rdr, pargs, readtype); },
         name + " [timeout]",
         "Search for tags, using Level 3 commands with " + description,
         "timeout -- Number of milliseconds to search.  Defaults to a reasonable average number.",
         "",
         name,
         name + " 3000");
 }