Beispiel #1
0
 public string ReadPassword(uint byteIndex, uint length)
 {
     try
     {
         DateTime timeBeforeRead = DateTime.Now;
         byte[] data = null;
         using (Reader reader = Reader.Create("tmr:///" + Vars.comport.ToLower()))
         {
             reader.Connect();
             TagOp tagOp = new Gen2.ReadData(Gen2.Bank.RESERVED, byteIndex, (byte)length);
             SimpleReadPlan plan = new SimpleReadPlan(null, TagProtocol.GEN2, null, tagOp, 1000);
             reader.ParamSet("/reader/read/plan", plan);
             data = reader.ReadTagMemBytes(tagData, (int)Gen2.Bank.RESERVED, (int)byteIndex, (int)length);
         }
         DateTime timeAfterRead = DateTime.Now;
         TimeSpan timeElapsed = timeAfterRead - timeBeforeRead;
         commandTotalTimeTextBox.Text = timeElapsed.TotalSeconds.ToString();
         return ByteFormat.ToHex(data);
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex.Message);
         return "";
     }
 }
Beispiel #2
0
 public void Kill()
 {
     try
     {
         DateTime timeBeforeRead = DateTime.Now;
         using (Reader reader = Reader.Create("tmr:///" + Vars.comport.ToLower()))
         {
             reader.Connect();
             uint killPassword = ByteConv.ToU32(ByteFormat.FromHex(textBox3.Text),0);
             TagOp tagOp = new Gen2.Kill(killPassword);
             SimpleReadPlan plan = new SimpleReadPlan(null, TagProtocol.GEN2, null, tagOp, 1000);
             reader.ParamSet("/reader/read/plan", plan);
             reader.ExecuteTagOp(tagOp, tagData);
         }
         DateTime timeAfterRead = DateTime.Now;
         TimeSpan timeElapsed = timeAfterRead - timeBeforeRead;
         commandTotalTimeTextBox.Text = timeElapsed.TotalSeconds.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        static void Main(string[] args)
        {
            // Program setup
            if (1 != args.Length)
            {
                Console.WriteLine(String.Join("\r\n", new string[] {
                    "Please provide reader URL, such as:",
                    "tmr:///com4",
                    "tmr://my-reader.example.com",
                }));
                Environment.Exit(1);
            }

            try
            {
                // Create Reader object, connecting to physical device.
                // Wrap reader in a "using" block to get automatic
                // 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();
                    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();
                        }
                        else
                        {
                            r.ParamSet("/reader/region/id", supportedRegions[0]);
                        }
                    }
                    
                    //Set delimiter to 1
                    r.ParamSet("/reader/iso180006b/delimiter", Iso180006b.Delimiter.DELIMITER1);

                    // Read Plan
                    Iso180006b.Select filter = new Iso180006b.Select(false, Iso180006b.SelectOp.NOTEQUALS, 0, 0xff, new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
                    SimpleReadPlan plan = new SimpleReadPlan(null, TagProtocol.ISO180006B, filter, null, 1000);
                    r.ParamSet("/reader/read/plan", plan);

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

                    // Create and add read exception listener
                    r.ReadException += new EventHandler<ReaderExceptionEventArgs>(r_ReadException);
                    // Search for tags in the background
                    r.StartReading();

                    Console.WriteLine("\r\n<Do other work here>\r\n");
                    Thread.Sleep(500);
                    Console.WriteLine("\r\n<Do other work here>\r\n");
                    Thread.Sleep(500);

                    r.StopReading();
                }
            }
            catch (ReaderException re)
            {
                Console.WriteLine("Error: " + re.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
 /// <summary>
 /// Perform read to get the access password
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnRead_Click(object sender, RoutedEventArgs e)
 {
     Mouse.SetCursor(Cursors.Wait);
     TagReadData[] tagReads = null;
     try
     {
         if (btnRead.Content.Equals("Read"))
         {
             SimpleReadPlan srp = new SimpleReadPlan(((null != GetSelectedAntennaList()) ? (new int[] { GetSelectedAntennaList()[0] }) : null), TagProtocol.GEN2, null, 0);
             objReader.ParamSet("/reader/read/plan", srp);
             tagReads = objReader.Read(500);
             if ((null != tagReads) && (tagReads.Length > 0))
             {
                 currentEPC = tagReads[0].EpcString;
                 txtEpc.Text = tagReads[0].EpcString;
                 lblSelectFilter.Content = "Showing tag: EPC ID = " + tagReads[0].EpcString;
                 if (tagReads.Length > 1)
                 {
                     lblLockTagError.Content = "Warning: More than one tag responded";
                     lblLockTagError.Visibility = System.Windows.Visibility.Visible;
                 }
                 else
                 {
                     lblLockTagError.Visibility = System.Windows.Visibility.Collapsed;
                 }
             }
             else
             {
                 txtEpc.Text = "";
                 currentEPC = string.Empty;
                 MessageBox.Show("No tags found", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                 return;
             }
         }
         else
         {
             rbSelectedTagLockTagTb.IsChecked = true;
         }
         //Display user bank data
         PopulateUserData();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.SetCursor(Cursors.Arrow);
     }
 }       
        static void Main(string[] args)
        {
            // Program setup
            if (1 != args.Length)
            {
                Console.WriteLine(String.Join("\r\n", new string[] {
                    "Please provide reader URL, such as:",
                    "tmr:///com4",
                    "tmr://my-reader.example.com",
                }));
                Environment.Exit(1);
            }

            try
            {
                // Create Reader object, connecting to physical device.
                // Wrap reader in a "using" block to get automatic
                // 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();
                    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();
                        }
                        else
                        {
                            r.ParamSet("/reader/region/id", supportedRegions[0]);
                        }
                    }

                    // Create a list of antennas
                    int[] antennaList = new int[] { 1 };

                    // Create a simplereadplan which uses the antenna list created above
                    SimpleReadPlan plan = new SimpleReadPlan(antennaList, TagProtocol.GEN2);

                    // Set the created readplan
                    r.ParamSet("/reader/read/plan", plan);

                    TagReadData[] tagReads;
                    // Read tags
                    tagReads = r.Read(500);
                    // Print tag reads
                    foreach (TagReadData tr in tagReads)
                        Console.WriteLine(tr.ToString());
                }
            }
            catch (ReaderException re)
            {
                Console.WriteLine("Error: " + re.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
        private void btnRead_Click(object sender, RoutedEventArgs e)
        {
            Mouse.SetCursor(Cursors.Wait);
            TagReadData[] tagReads;
            try
            {
                if ((bool)rbFirstTag.IsChecked)
                {
                    SimpleReadPlan srp = new SimpleReadPlan(((null != GetSelectedAntennaList())?(new int[] { GetSelectedAntennaList()[0]}):null), TagProtocol.GEN2, null, 0);
                    objReader.ParamSet("/reader/read/plan", srp);
                    tagReads = objReader.Read(500);
                }
                else
                {
                    SetReadPlan();
                    tagReads = objReader.Read(500);
                }

                if ((null != tagReads) && (tagReads.Length > 0))
                {
                    if ((bool)rbASCIIRep.IsChecked)
                    {
                        txtCurrentEpc.Text = Utilities.HexStringToAsciiString(tagReads[0].EpcString);                        
                    }
                    else if ((bool)rbReverseBase36Rep.IsChecked)
                    {
                        txtCurrentEpc.Text = Utilities.ConvertHexToBase36(tagReads[0].EpcString);
                    }
                    else
                    {
                        txtCurrentEpc.Text = tagReads[0].EpcString;
                    }
                    if (tagReads.Length > 1)
                    {
                        lblError.Content = "Warning: More than one tag responded";
                        lblError.Visibility = System.Windows.Visibility.Visible;
                    }
                    else
                    {
                        lblError.Visibility = System.Windows.Visibility.Collapsed;
                    }
                    currentEpc = txtCurrentEpc.Text;
                }
                else
                {
                    txtCurrentEpc.Text = "";
                    MessageBox.Show("No tags found", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                Mouse.SetCursor(Cursors.Arrow);
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            // Program setup
            if (1 != args.Length)
            {
                Console.WriteLine(String.Join("\r\n", new string[] {
                    "Please provide reader URL, such as:",
                    "tmr:///com4",
                    "tmr://my-reader.example.com",
                }));
                Environment.Exit(1);
            }

            try
            {
                // Create Reader object, connecting to physical device.
                // Wrap reader in a "using" block to get automatic
                // 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();
                    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();
                        }
                        else
                        {
                            r.ParamSet("/reader/region/id", supportedRegions[0]);
                        }
                    }
                    TagReadData[] tagReads;
                    TagFilter filter;
                    byte[] mask = new byte[4];
                    Gen2.Impinj.Monza4.QTPayload payLoad;
                    Gen2.Impinj.Monza4.QTControlByte controlByte;
                    Gen2.Impinj.Monza4.QTReadWrite readWrite;
                    uint accesspassword = 0;

                    r.ParamSet("/reader/tagop/antenna", 1);

                    Gen2.Session session = Gen2.Session.S0;
                    r.ParamSet("/reader/gen2/session", session);

                    SimpleReadPlan readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, null, null, 1000);
                    r.ParamSet("/reader/read/plan", readPlan);

                    // Reading tags with a Monza 4 public EPC in response
                    Console.WriteLine("Reading tags with a Monza 4 public EPC in response");
                    tagReads = r.Read(1000);
                    foreach (TagReadData tagData in tagReads)
                    {
                         Console.WriteLine("Monza4 tag epc: " +tagData.EpcString);
                    }
                    Console.WriteLine();

                    // Initialize the payload and the controlByte of Monza4
                    payLoad = new Gen2.Impinj.Monza4.QTPayload();
                    controlByte = new Gen2.Impinj.Monza4.QTControlByte();

                    Console.WriteLine("Changing to private Mode ");
                    // Executing Monza4 QT Write Set Private tagop
                    payLoad.QTMEM = false;
                    payLoad.QTSR = false;
                    controlByte.QTReadWrite = true;
                    controlByte.Persistence = true;

                    readWrite = new Gen2.Impinj.Monza4.QTReadWrite(accesspassword, payLoad, controlByte);
                    r.ExecuteTagOp(readWrite, null);
                    Console.WriteLine();

                    // Setting the session to S2
                    session = Gen2.Session.S2;
                    r.ParamSet("/reader/gen2/session", session);

                    // Enable filter
                    mask[0] = (byte) 0x20;
                    mask[1] = (byte) 0x01;
                    mask[2] = (byte) 0xB0;
                    mask[3] = (byte) 0x00;
                    filter = new Gen2.Select(true, Gen2.Bank.TID, 0x04, 0x18, mask);

                    Console.WriteLine("Reading tags private Mode with session s2 ");
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, null, 1000);
                    r.ParamSet("/reader/read/plan", readPlan);
                    // Reading tags with a Monza 4 FastID with TID in response
                    Console.WriteLine("Reading tags with a Monza 4 FastID with TID in response");
                    tagReads = r.Read(1000);
                    foreach (TagReadData tagData in tagReads)
                    {
                         Console.WriteLine("Monza4 tag epc: " +tagData.EpcString);
                    }
                    Console.WriteLine();
                    
                    Console.WriteLine("Setting the session to S0");

                    // Setting the session to S0
                    session = Gen2.Session.S0;
                    r.ParamSet("/reader/gen2/session", session);

                    mask[0] = (byte) 0xE2;
                    mask[1] = (byte) 0x80;
                    mask[2] = (byte) 0x11;
                    mask[3] = (byte) 0x05;
                    filter = new Gen2.Select(false, Gen2.Bank.TID, 0x00, 0x20, mask);
                    Console.WriteLine("Reading tags private Mode with session s0 ");
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, null, 1000);
                    r.ParamSet("/reader/read/plan", readPlan);
                    // Reading tags with a Monza 4 FastID with NO TID in response
                    Console.WriteLine("Reading tags with a Monza 4 FastID with NO TID in response");
                    tagReads = r.Read(1000);
                    foreach (TagReadData tagData in tagReads)
                    {
                         Console.WriteLine("Monza4 tag epc: " +tagData.EpcString);
                    }
                    Console.WriteLine();

                    Console.WriteLine("Converting to public mode");
                    // Executing  Monza4 QT Write Set Public tagop
                    payLoad.QTMEM = true;
                    payLoad.QTSR = false;
                    controlByte.QTReadWrite = true;
                    controlByte.Persistence = true;

                    readWrite = new Gen2.Impinj.Monza4.QTReadWrite(accesspassword, payLoad, controlByte);
                    r.ExecuteTagOp(readWrite, null);
                    Console.WriteLine();

                    // Enable filter
                    mask[0] = (byte) 0x20;
                    mask[1] = (byte) 0x01;
                    mask[2] = (byte) 0xB0;
                    mask[3] = (byte) 0x00;
                    filter = new Gen2.Select(true, Gen2.Bank.TID, 0x04, 0x18, mask);
                    Console.WriteLine("Reading tags public Mode with session s0 ");
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, null, 1000);
                    r.ParamSet("/reader/read/plan", readPlan);
                    // Reading tags with a Monza 4 FastID with TID in response
                    tagReads = r.Read(1000);
                    foreach (TagReadData tagData in tagReads)
                    {
                         Console.WriteLine("Monza4 tag epc: " +tagData.EpcString);
                    }
                    Console.WriteLine();
                   
                    Console.WriteLine("Reset the Read protect on ");
                    // Reset the Read protect on
                    payLoad.QTMEM = false;
                    payLoad.QTSR = false;
                    controlByte.QTReadWrite = false;
                    controlByte.Persistence = false;

                    readWrite = new Gen2.Impinj.Monza4.QTReadWrite(accesspassword, payLoad, controlByte);
                    r.ExecuteTagOp(readWrite, null);
                }
            }
            catch (ReaderException re)
            {
                Console.WriteLine("Error: " + re.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
        static void Main(string[] args)
        {
            // Program setup
            if (1 != args.Length)
            {
                Console.WriteLine(String.Join("\r\n", new string[] {
                    "Please provide reader URL, such as:",
                    "tmr:///com4",
                    "tmr://my-reader.example.com",
                }));
                Environment.Exit(1);
            }

            try
            {
                // Create Reader object, connecting to physical device.
                // Wrap reader in a "using" block to get automatic
                // 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();
                    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();
                        }
                        else
                        {
                            r.ParamSet("/reader/region/id", supportedRegions[0]);
                        }
                    }
                    // Read Plan
                    byte length;
                    string model = (string)r.ParamGet("/reader/version/model");
                    if ("M6e".Equals(model)
                        || "M6e PRC".Equals(model)
                        || "M6e Micro".Equals(model)
                        || "Mercury6".Equals(model)
                        || "Astra-EX".Equals(model))
                    {
                        // Specifying the readLength = 0 will return full TID for any tag read in case of M6e varients, M6 and Astra-EX reader.
                        length = 0;
                    }
                    else
                    {
                        length = 2;
                    }
                    
                    // Embedded Secure Read Tag Operation - Standalone operation not supported
                    Gen2.Password password = new Gen2.Password(0);
                    Gen2.SecureReadData secureReadDataTagOp = new Gen2.SecureReadData(Gen2.Bank.TID, 0, (byte)0, Gen2.SecureTagType.HIGGS3, password); ;
                    SimpleReadPlan plan = new SimpleReadPlan(null, TagProtocol.GEN2, null, secureReadDataTagOp, 1000);
                    r.ParamSet("/reader/read/plan", plan);

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

                    // Create and add read exception listener
                    r.ReadException += r_ReadException;

                    // Create and add read authenticate listener
                    r.ReadAuthentication += r_ReadAuthenticationListener;

                    // Search for tags in the background
                    r.StartReading();

                    Console.WriteLine("\r\n<Do other work here>\r\n");
                    Thread.Sleep(500);
                    Console.WriteLine("\r\n<Do other work here>\r\n");
                    Thread.Sleep(500);

                    r.StopReading();
                }
            }
            catch (ReaderException re)
            {
                Console.WriteLine("Error: " + re.Message);
                Console.Out.Flush();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
        private void btnRead_Click(object sender, RoutedEventArgs e)
        {
            Mouse.SetCursor(Cursors.Wait);
            TagReadData[] tagReads = null;
            try
            {
                rbEPCAscii.IsEnabled = true;
                rbEPCBase36.IsEnabled = true;
                if (btnRead.Content.Equals("Read"))
                {
                    SimpleReadPlan srp = new SimpleReadPlan(((null != GetSelectedAntennaList()) ? (new int[] { GetSelectedAntennaList()[0] }) : null), TagProtocol.GEN2, null, 0);
                    objReader.ParamSet("/reader/read/plan", srp);
                    tagReads = objReader.Read(500);
                    if ((null != tagReads) && (tagReads.Length > 0))
                    {
                        currentEPC = tagReads[0].EpcString;
                        if ((bool)rbEPCAscii.IsChecked)
                        {
                            txtEpc.Text = Utilities.HexStringToAsciiString(tagReads[0].EpcString);
                        }
                        else if ((bool)rbEPCBase36.IsChecked)
                        {
                            txtEpc.Text = Utilities.ConvertHexToBase36(tagReads[0].EpcString);
                        }
                        else
                        {
                            txtEpc.Text = tagReads[0].EpcString;
                        }
                        lblSelectFilter.Content = "Showing tag: EPC ID = " + tagReads[0].EpcString;
                        if (tagReads.Length > 1)
                        {
                            lblTagInspectorError.Content = "Warning: More than one tag responded";
                            lblTagInspectorError.Visibility = System.Windows.Visibility.Visible;
                        }
                        else
                        {
                            lblTagInspectorError.Visibility = System.Windows.Visibility.Collapsed;
                        }
                    }
                    else
                    {
                        txtEpc.Text = "";
                        currentEPC = string.Empty;
                        MessageBox.Show("No tags found", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    rbSelectedTagIns.IsChecked = true;
                }

                PopulateData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                Mouse.SetCursor(Cursors.Arrow);
            }
        }
Beispiel #10
0
        private static void TestStrFilterReadPlansFunc(Reader rdr, ArgParser pargs)
        {
            Gen2.Select g2s = new Gen2.Select(false, Gen2.Bank.EPC, 16, 16, new byte[] { 0x12, 0x34 });
            Console.WriteLine(g2s);
            Gen2.Select notg2s = new Gen2.Select(true, Gen2.Bank.EPC, 16, 16, new byte[] { 0x12, 0x34 });
            Console.WriteLine(notg2s);
            Iso180006b.Select i6bs = new Iso180006b.Select(false, Iso180006b.SelectOp.EQUALS, 0, 0xC0, new byte[] { 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
            Console.WriteLine(i6bs);
            Iso180006b.Select noti6bs = new Iso180006b.Select(true, Iso180006b.SelectOp.EQUALS, 0, 0xC0, new byte[] { 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
            Console.WriteLine(noti6bs);
            TagData td = new TagData("1234567890ABCDEF");
            Console.WriteLine(td);
            MultiFilter mf = new MultiFilter(new TagFilter[] { g2s, i6bs, td });
            Console.WriteLine(mf);

            SimpleReadPlan srp1 = new SimpleReadPlan(null, TagProtocol.GEN2, g2s, 1000);
            Console.WriteLine(srp1);
            SimpleReadPlan srp2 = new SimpleReadPlan(new int[] { 1, 2 }, TagProtocol.ISO180006B, i6bs, 1000);
            Console.WriteLine(srp2);
            MultiReadPlan mrp = new MultiReadPlan(new ReadPlan[] { srp1, srp2 });
            Console.WriteLine(mrp);
        }
Beispiel #11
0
 /// <summary>
 /// Parse string representing a parameter value.
 /// </summary>
 /// <param name="name">Name of parameter</param>
 /// <param name="valstr">String to be parsed into a parameter value</param>
 private static Object ParseValue(string name, string valstr)
 {
     Object value = ParseValue(valstr);
     switch (name.ToLower())
     {
         case "/reader/antenna/portswitchgpos":
         case "/reader/region/hoptable":
             value = ((ArrayList)value).ToArray(typeof(int));
             break;
         case "/reader/gpio/inputlist":
             value = ((ArrayList)value).ToArray(typeof(int));
             break;
         case "/reader/gpio/outputlist":
             value = ((ArrayList)value).ToArray(typeof(int));
             break;
         case "/reader/antenna/settlingtimelist":
         case "/reader/antenna/txrxmap":
         case "/reader/radio/portreadpowerlist":
         case "/reader/radio/portwritepowerlist":
             value = ArrayListToInt2Array((ArrayList)value);
             break;
         case "/reader/region/lbt/enable":
         case "/reader/antenna/checkport":
         case "/reader/tagreaddata/recordhighestrssi":
         case "/reader/tagreaddata/uniquebyantenna":
         case "/reader/tagreaddata/uniquebydata":
         case "/reader/tagreaddata/reportrssiindbm":
             value = ParseBool(valstr);
             break;
         case "/reader/read/plan":
             // Special Case: If value is list of integers, automatically
             // interpret as SimpleReadPlan with list of antennas.
             if (value is ArrayList)
             {
                 int[] antList = (int[])((ArrayList)value).ToArray(typeof(int));
                 SimpleReadPlan srp = new SimpleReadPlan();
                 srp.Antennas = antList;
                 value = srp;
             }
             break;
         case "/reader/region/id":
             value = Enum.Parse(typeof(Reader.Region), (string)value, true);
             break;
         case "/reader/powermode":
             value = Enum.Parse(typeof(Reader.PowerMode), (string)value, true);
             break;
         case "/reader/tagop/protocol":
             if (value is string)
             {
                 value = Enum.Parse(typeof(TagProtocol), (string)value, true);
             }
             break;
         case "/reader/gen2/accesspassword":
             value = new Gen2.Password((UInt32)(int)value);
             break;
         case "/reader/gen2/session":
             if (value is int)
             {
                 switch ((int)value)
                 {
                     case 0: return Gen2.Session.S0;
                     case 1: return Gen2.Session.S1;
                     case 2: return Gen2.Session.S2;
                     case 3: return Gen2.Session.S3;
                 }
             }
             break;
         case "/reader/gen2/tagencoding":
             value = Enum.Parse(typeof(Gen2.TagEncoding), (string)value, true);
             break;
         case "/reader/iso180006b/blf":
             if (value is string)
             {
                 value = Enum.Parse(typeof(Iso180006b.LinkFrequency), (string)value, true);
             }
             break;
         default:
             break;
     }
     return value;
 }
Beispiel #12
0
        private void ReadtheTags()
        {
            try
            {
                // Make sure reader is connected
                ReadMgr.GetReader();

                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

                if (btnStartReads.Text == "Start Reads")
                {
                    Cursor.Current = Cursors.WaitCursor;
                    try
                    {
                        //Check the battery power level
                        if (CoreDLL.GetSystemPowerStatusEx(status, false) == 1)
                        {
                            if (status.BatteryLifePercent <= 5)
                            {
                                if (status.ACLineStatus == 0)
                                {
                                    MessageBox.Show("Battery level is low to read tags");
                                    return;
                                }
                            }
                        }
                        properties["isreading"] = "yes";
                        Utilities.SaveConfigurations(properties);

                        //disable read power coverage
                        tbTXPower.Enabled = false;

                        ReadMgr.GetReader().ParamSet("/reader/transportTimeout", 2000);
                        int powerLevel = Convert.ToInt32(properties["readpower"]);
                        ReadMgr.GetReader().ParamSet("/reader/radio/readPower", powerLevel);
                        Utilities.SwitchRegion(properties["region"]);
                        ReadMgr.GetReader().ParamSet("/reader/antenna/txRxMap", new int[][] { new int[] { 1, 1, 1 } });
                        ant.Add(1);
                        SimpleReadPlan plan = new SimpleReadPlan(ant.ToArray(), TagProtocol.GEN2);
                        ReadMgr.GetReader().ParamSet("/reader/read/plan", plan);
                        //int readPower = Convert.ToInt32(properties["readpower"].ToString()) * 100;
                        //tbTXPower.Value = (readPower - 1000) / 50;

                        tmrBackLightControl.Enabled = true;
                        miGoToMain.Enabled = false;

                        //set properties
                        ReadMgr.GetReader().ParamSet("/reader/read/asyncOffTime", 50);
                        ReadMgr.GetReader().ParamSet("/reader/powerMode", Reader.PowerMode.FULL);

                        //set the tag population settings
                        ReadMgr.GetReader().ParamSet("/reader/gen2/target", Gen2.Target.A);//default target
                        string tagPopulation = properties["tagpopulation"];
                        switch (tagPopulation)
                        {
                            case "small":
                                ReadMgr.GetReader().ParamSet("/reader/gen2/q", new Gen2.StaticQ(2));
                                ReadMgr.GetReader().ParamSet("/reader/gen2/session", Gen2.Session.S0);
                                ReadMgr.GetReader().ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.M4);
                                break;
                            case "medium":
                                ReadMgr.GetReader().ParamSet("/reader/gen2/q", new Gen2.StaticQ(4));
                                ReadMgr.GetReader().ParamSet("/reader/gen2/session", Gen2.Session.S1);
                                ReadMgr.GetReader().ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.M4);
                                break;
                            case "large":
                                ReadMgr.GetReader().ParamSet("/reader/gen2/q", new Gen2.StaticQ(6));
                                ReadMgr.GetReader().ParamSet("/reader/gen2/session", Gen2.Session.S1);
                                ReadMgr.GetReader().ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.M2);
                                break;
                            default: break;
                        }

                        if (null != properties)
                        {
                            Utilities.SetReaderSettings(ReadMgr.GetReader(), properties);
                        }
                        else
                            MessageBox.Show("properties are null");
                        //set the read plan and filter
                        TagFilter filter;
                        int addressToRead = int.Parse(properties["selectionaddress"]);
                        Gen2.Bank bank = Gen2.Bank.EPC;
                        switch (properties["tagselection"].ToLower())
                        {
                            case "None":
                            case "epc": bank = Gen2.Bank.EPC; break;
                            case "tid": bank = Gen2.Bank.TID; break;
                            case "user": bank = Gen2.Bank.USER; break;
                            case "reserved": bank = Gen2.Bank.RESERVED; break;
                            default: break;

                        }
                        if ("yes" == properties["ismaskselected"])
                        {
                            filter = new Gen2.Select(true, bank, (uint)addressToRead * 8, (ushort)(properties["selectionmask"].Length * 4), ByteFormat.FromHex(properties["selectionmask"]));
                        }
                        else
                        {
                            filter = new Gen2.Select(false, bank, (uint)addressToRead * 8, (ushort)(properties["selectionmask"].Length * 4), ByteFormat.FromHex(properties["selectionmask"]));
                        }

                        SimpleReadPlan srp;
                        if (properties["tagselection"].ToLower() == "none")
                        {
                            srp = new SimpleReadPlan(new int[] { 1 }, TagProtocol.GEN2, null, 0);
                        }
                        else
                        {
                            srp = new SimpleReadPlan(new int[] { 1 }, TagProtocol.GEN2, filter, 0);
                        }
                        ReadMgr.GetReader().ParamSet("/reader/read/plan", srp);

                        btnStartReads.Text = "Stop Reads";
                        setStatus("Reading", System.Drawing.Color.DarkGoldenrod);
                        ReadMgr.GetReader().ReadException += ReadException;
                        ReadMgr.GetReader().TagRead += PrintTagRead;
                        ReadMgr.GetReader().StartReading();
                        if (properties["audiblealert"].ToLower() == "yes")
                        {
                            if (readTriggeredByTap)
                            {
                                playStartSound();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.ToString());
                        tbTXPower.Enabled = true;
                        //MessageBox.Show("Error connecting to reader: " + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        btnStartReads.Text = "Start Reads";
                        setStatus(Status.IDLE);
                        ReadMgr.GetReader().ParamSet("/reader/powerMode", Reader.PowerMode.MAXSAVE);
                        miGoToMain.Enabled = true;
                        tmrBackLightControl.Enabled = false;
                        properties["isreading"] = "no";
                        Utilities.SaveConfigurations(properties);
                        throw ex;
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                    }
                }
                else if (btnStartReads.Text == "Stop Reads")
                {
                    logger.Debug("Stop Reads pressed: Calling StopReads from ReadtheTags");
                    StopReads();
                    logger.Debug("Stop Reads pressed: Called StopReads from ReadtheTags");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                if (-1 != ex.Message.IndexOf("RFID reader was not found"))
                {
                    MessageBox.Show(ex.Message, "Error");
                }
                else
                {
                    btnStartReads.Text = "Start Reads";
                    setStatus(Status.IDLE);
                    properties["isreading"] = "no";
                    Utilities.SaveConfigurations(properties);
                    throw ex;
                }
            }
        }
 private LTKD.Parameter BuildOpSpec(SimpleReadPlan srp) 
 {
     TagOp tagOp = srp.Op;
     if(tagOp is Gen2.ReadData)
     {
         return BuildReadOpSpec((Gen2.ReadData)tagOp);
     }
     if (tagOp is Gen2.WriteData)
     {
         return BuildWriteDataOpSpec(tagOp);
     }
     if (tagOp is Gen2.WriteTag)
     {
         return BuildWriteTagOpSpec(tagOp);
     }
     if(tagOp is Gen2.BlockWrite)
     {
         return BuildBlockWriteTagOpSpec((Gen2.BlockWrite)tagOp);
     }
     if (tagOp is Gen2.Lock)
     {
         return BuildLockTagOpSpec((Gen2.Lock)tagOp);
     }
     if (tagOp is Gen2.Kill)
     {
         return BuildKillTagOpSpec((Gen2.Kill)tagOp);
     }
     if (tagOp is Gen2.BlockPermaLock)
     {
         return BuildBlockPermaLockTagOpSpec((Gen2.BlockPermaLock)tagOp);
     }
     if (tagOp is Gen2.BlockErase)
     {
         return BuildBlockEraseOpSpec((Gen2.BlockErase)tagOp);
     }
     if (tagOp is Gen2.Alien.Higgs2.PartialLoadImage)
     {
         return BuildHiggs2PartialLoadImage((Gen2.Alien.Higgs2.PartialLoadImage)tagOp);
     }
     if (tagOp is Gen2.Alien.Higgs2.FullLoadImage)
     {
         return BuildHiggs2FullLoadImage((Gen2.Alien.Higgs2.FullLoadImage)tagOp);
     }
     if (tagOp is Gen2.Alien.Higgs3.FastLoadImage)
     {
         return BuildHiggs3FastLoadImage((Gen2.Alien.Higgs3.FastLoadImage)tagOp);
     }
     if (tagOp is Gen2.Alien.Higgs3.LoadImage)
     {
         return BuildHiggs3LoadImage((Gen2.Alien.Higgs3.LoadImage)tagOp);
     }
     if (tagOp is Gen2.Alien.Higgs3.BlockReadLock)
     {
         return BuildHiggs3BlockReadLock((Gen2.Alien.Higgs3.BlockReadLock)tagOp);
     }
     if (tagOp is Gen2.NxpGen2TagOp.SetReadProtect)
     {
         return BuildNxpGen2SetReadProtect((Gen2.NxpGen2TagOp.SetReadProtect)tagOp);
     }
     if (tagOp is Gen2.NxpGen2TagOp.ResetReadProtect)
     {
         return BuildNxpGen2ResetReadProtect((Gen2.NxpGen2TagOp.ResetReadProtect)tagOp);
     }
     if (tagOp is Gen2.NxpGen2TagOp.ChangeEas)
     {
         return BuildNxpGen2ChangeEAS((Gen2.NxpGen2TagOp.ChangeEas)tagOp);
     }
     if (tagOp is Gen2.NxpGen2TagOp.Calibrate)
     {
         return BuildNxpGen2Calibrate((Gen2.NxpGen2TagOp.Calibrate)tagOp);
     }
     if (tagOp is Gen2.NXP.G2I.ChangeConfig)
     {
         return BuildNxpG2IChangeConfig((Gen2.NXP.G2I.ChangeConfig)tagOp);
     }
     if (tagOp is Gen2.Impinj.Monza4.QTReadWrite)
     {
         return BuildMonza4QTReadWrite((Gen2.Impinj.Monza4.QTReadWrite)tagOp);
     }
     if (tagOp is Gen2.NxpGen2TagOp.EasAlarm)
     {
         return BuildNxpGen2EASAlarm((Gen2.NxpGen2TagOp.EasAlarm)tagOp);
     }
     if (tagOp is Iso180006b.ReadData)
     {
         return BuildIso180006bReadDataOpSpec((Iso180006b.ReadData)tagOp);
     }
     if (tagOp is Iso180006b.WriteData)
     {
         return BuildIso180006bWriteTagDataOpSpec((Iso180006b.WriteData)tagOp);
     }
     if (tagOp is Iso180006b.LockTag)
     {
         return BuildIso180006bLockTagOpSpec((Iso180006b.LockTag)tagOp);
     }
     else if (tagOp is Gen2.IDS.SL900A.SetCalibrationData)
     {
         return BuildIDsSL900aSetCalibrationDataTagOpSpec((Gen2.IDS.SL900A.SetCalibrationData)tagOp);
     }
     else if(tagOp is Gen2.IDS.SL900A.EndLog)
     {
         return BuildIDsSL900aEndLogTagOpSpec((Gen2.IDS.SL900A.EndLog)tagOp);
     }
     else if(tagOp is Gen2.IDS.SL900A.Initialize)
     {
         return BuildIDsSL900aInitializeTagOpSpec((Gen2.IDS.SL900A.Initialize)tagOp);
     } 
     else if(tagOp is Gen2.IDS.SL900A.SetLogMode)
     {
         return BuildIDsSL900aSetLogModeTagOpSpec((Gen2.IDS.SL900A.SetLogMode)tagOp);
     }
     else if(tagOp is Gen2.IDS.SL900A.StartLog)
     {
         return BuildIDsSL900aStartLogTagOpSpec((Gen2.IDS.SL900A.StartLog)tagOp);
     }
     else if(tagOp is Gen2.IDS.SL900A.SetSfeParameters)
     {
         return BuildIDsSL900aSetSFEParamsTagOpSpec((Gen2.IDS.SL900A.SetSfeParameters)tagOp);
     }
     else if(tagOp is  Gen2.IDS.SL900A.SetLogLimit)
     {
         return BuildIDsSL900aSetLogLimitsTagOpSpec((Gen2.IDS.SL900A.SetLogLimit)tagOp);
     }
     else if(tagOp is Gen2.IDS.SL900A.SetPassword)
     {
         return BuildIDsSL900aSetIDSPasswordTagOpSpec((Gen2.IDS.SL900A.SetPassword)tagOp);
     }
     else if (tagOp is Gen2.IDS.SL900A.GetSensorValue)
     {
         return BuildIDsSL900aSensorValueTagOpSpec((Gen2.IDS.SL900A.GetSensorValue)tagOp);
     }
     else if (tagOp is Gen2.IDS.SL900A.GetBatteryLevel)
     {
         return BuildIDsSL900aBatteryLevelTagOpSpec((Gen2.IDS.SL900A.GetBatteryLevel)tagOp);
     }
     else if (tagOp is Gen2.IDS.SL900A.GetCalibrationData)
     {
         return BuildIDsSL900aGetCalibrationDataTagOpSpec((Gen2.IDS.SL900A.GetCalibrationData)tagOp);
     }
     else if (tagOp is Gen2.IDS.SL900A.GetLogState)
     {
         return BuildIDsSL900aLoggingFormTagOpSpec((Gen2.IDS.SL900A.GetLogState)tagOp);
     }
     else if (tagOp is Gen2.IDS.SL900A.GetMeasurementSetup)
     {
         return BuildIDSsL900aGetMeasurementSetupTagOpSpec((Gen2.IDS.SL900A.GetMeasurementSetup)tagOp);
     }
     else if (tagOp is Gen2.IDS.SL900A.AccessFifo)
     {
         return BuildIDsSL900aAccessFifoTagOpSpec((Gen2.IDS.SL900A.AccessFifo)tagOp);
     }
     else if(tagOp is Gen2.IDS.SL900A.SetShelfLife)
     {
         return BuildIDsSL900aSetShelfLifeTagOpSpec((Gen2.IDS.SL900A.SetShelfLife)tagOp);
     }
     else if (tagOp is Gen2.Denatran.IAV.ActivateSecureMode)
     {
         return BuildIAVActivateSecureMode((Gen2.Denatran.IAV.ActivateSecureMode)tagOp);
     }
     else if (tagOp is Gen2.Denatran.IAV.ActivateSiniavMode)
     {
         return BuildIAVActivateSiniavMode((Gen2.Denatran.IAV.ActivateSiniavMode)tagOp);
     }
     else if (tagOp is Gen2.Denatran.IAV.AuthenticateOBU)
     {
         return BuildIAVAuthenticateOBU((Gen2.Denatran.IAV.AuthenticateOBU)tagOp);
     }
     else if (tagOp is Gen2.Denatran.IAV.OBUAuthFullPass1)
     {
         return BuildIAVOBUAuthenticateFullPass1((Gen2.Denatran.IAV.OBUAuthFullPass1)tagOp);
     }
     else if (tagOp is Gen2.Denatran.IAV.OBUAuthFullPass2)
     {
         return BuildIAVOBUAuthenticateFullPass2((Gen2.Denatran.IAV.OBUAuthFullPass2)tagOp);
     }
     else if (tagOp is Gen2.Denatran.IAV.OBUAuthID)
     {
         return BuildIAVOBUAuthenticateID((Gen2.Denatran.IAV.OBUAuthID)tagOp);
     }
     else if (tagOp is Gen2.Denatran.IAV.OBUReadFromMemMap)
     {
         return BuildIAVOBUReadFromMemMap((Gen2.Denatran.IAV.OBUReadFromMemMap)tagOp);
     }
     else if (tagOp is Gen2.Denatran.IAV.OBUWriteToMemMap)
     {
         return BuildIAVOBUWriteToMemMap((Gen2.Denatran.IAV.OBUWriteToMemMap)tagOp);
     }
     else
     {
         throw new FeatureNotSupportedException("Tag Operation not supported");
     }
 }
        /// <summary>
        /// execute a TagOp
        /// </summary>
        /// <param name="tagOP">Tag Operation</param>
        /// <param name="target">Tag filter</param>
        ///<returns>the return value of the tagOp method if available</returns>
        public override Object ExecuteTagOp(TagOp tagOP, TagFilter target)
        {
            //Delegate to receive the Ro Access report
            llrp.OnRoAccessReportReceived += new delegateRoAccessReport(TagOpOnRoAccessReportReceived);
            reportReceived = false;
            isRoAccessReportReceived = false;
            roSpecId = 0;
            
            /*  Reset Reader
            * Delete all ROSpec and AccessSpecs on the reader, so that
            * we don't have to worry about the prior configuration
            * No need to verify the error status. */

            DeleteRoSpec();
            DeleteAccessSpecs();           
            //Though its a standalone tag operation, From server point of view
            //we need to submit requests in the following order.

            // Add ROSpec 
            // Enable ROSpec
            // Add AccessSpec
            // Enable AccessSpec
            // Start ROSpec
            // Wait for response and verify the result

            SimpleReadPlan srp = new SimpleReadPlan();
            srp.Filter = target;
            roSpecProtcolTable = new Hashtable();
            if (tagOP.GetType().Equals(typeof(Iso180006b.ReadData))
                || tagOP.GetType().Equals(typeof(Iso180006b.WriteData)) 
                || tagOP.GetType().Equals(typeof(Iso180006b.LockTag)))
            {
                srp.Protocol = TagProtocol.ISO180006B;
            }
            else
            {
                srp.Protocol = (TagProtocol)ParamGet("/reader/tagop/protocol");
            }
            srp.Antennas = new int[] { (int)ParamGet("/reader/tagop/antenna")};
            srp.Op = tagOP;
            List<PARAM_ROSpec> roSpecList = new List<PARAM_ROSpec>();
            TagQueueEmptyEvent.Reset();
            try
            {
                BuildRoSpec(srp, 0, roSpecList,true);
                if (AddRoSpec(roSpecList[0]))
                {
                    if (EnableRoSpec(roSpecList[0].ROSpecID))
                    {
                        if (!StartRoSpec(roSpecList[0].ROSpecID))
                            return null;
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                throw new ReaderException(ex.ToString());
            }
            WaitForSearchEnd(0);
            //wait for ro access report
            while (!reportReceived)
            {
                Thread.Sleep(20);
            }
            ReaderException tempReaderexception = rx;
            try
            {
                if (null == rx)
                {
                    //Update tagOpResponse in UpdateRoReport;
                    if ((tagOP is Gen2.ReadData) 
                        || (tagOP is Gen2.BlockPermaLock) 
                        || (tagOP is Gen2.Impinj.Monza4.QTReadWrite) 
                        || (tagOP is Gen2.NxpGen2TagOp.Calibrate) 
                        || (tagOP is Gen2.NxpGen2TagOp.EasAlarm) 
                        || (tagOP is Gen2.NXP.G2I.ChangeConfig)
                        || (tagOP is Iso180006b.ReadData)
                        || (tagOP is Gen2.IDS.SL900A.GetBatteryLevel) 
                        || (tagOP is Gen2.IDS.SL900A.GetSensorValue)
                        || (tagOP is Gen2.IDS.SL900A.GetLogState)
                        || (tagOP is Gen2.IDS.SL900A.GetCalibrationData) 
                        || (tagOP is Gen2.IDS.SL900A.GetMeasurementSetup)
                        || (tagOP is Gen2.IDS.SL900A.AccessFifoRead)
                        || (tagOP is Gen2.IDS.SL900A.AccessFifoStatus)
                        || (tagOP is Gen2.Denatran.IAV.ActivateSecureMode)
                        || (tagOP is Gen2.Denatran.IAV.ActivateSiniavMode)
                        || (tagOP is Gen2.Denatran.IAV.AuthenticateOBU)
                        || (tagOP is Gen2.Denatran.IAV.OBUAuthFullPass1)
                        || (tagOP is Gen2.Denatran.IAV.OBUAuthFullPass2)
                        || (tagOP is Gen2.Denatran.IAV.OBUAuthID)
                        || (tagOP is Gen2.Denatran.IAV.OBUReadFromMemMap)
                        || (tagOP is Gen2.Denatran.IAV.OBUWriteToMemMap))
                    {
                        return tagOpResponse;
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    tempReaderexception = rx;
                    rx = null;
                    throw tempReaderexception;
                }
            }
            finally
            {
                tempReaderexception = null;
            }
        }
        static void Main(string[] args)
        {
            // Program setup
            if (1 != args.Length)
            {
                Console.WriteLine(String.Join("\r\n", new string[] {
                    "Please provide reader URL, such as:",
                    "tmr:///com4",
                    "tmr://my-reader.example.com",
                }));
                Environment.Exit(1);
            }

            try
            {
                // Create Reader object, connecting to physical device.
                // Wrap reader in a "using" block to get automatic
                // 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();
                    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();
                    }
                        else
                        {
                            r.ParamSet("/reader/region/id", supportedRegions[0]);
                        }
                    }
                    TagReadData[] tagReads;

                    // Read Plan
                    byte length;
                    string model = (string)r.ParamGet("/reader/version/model");
                    if ("M6e".Equals(model)
                        || "M6e PRC".Equals(model)
                        || "M6e Micro".Equals(model)
                        || "Mercury6".Equals(model)
                        || "Astra-EX".Equals(model))
                    {
                        // Specifying the readLength = 0 will return full TID for any tag read in case of M6e varients, M6 and Astra-EX reader.
                        length = 0;
                    }
                    else
                    {
                        length = 2;
                    }
                    TagOp op = new Gen2.ReadData(Gen2.Bank.TID, 0, length);
                    SimpleReadPlan plan = new SimpleReadPlan(null, TagProtocol.GEN2, null, op, 1000);
                    r.ParamSet("/reader/read/plan", plan);

                    // Read tags
                    tagReads = r.Read(500);
                    // Print tag reads
                    foreach (TagReadData tr in tagReads)
                    {
                        Console.WriteLine(tr.ToString());
                        if (0 < tr.Data.Length)
                        {
                            Console.WriteLine("  Data:" + ByteFormat.ToHex(tr.Data, "", " "));
                        } 
                    }
                }
            }
            catch (ReaderException re)
            {
                Console.WriteLine("Error: " + re.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
Beispiel #16
0
 public void WritePassword(uint byteIndex, string password)
 {
     try
     {
         DateTime timeBeforeRead = DateTime.Now;
         ushort[] data = ByteConv.ToU16s(ByteFormat.FromHex(password));
         using (Reader reader = Reader.Create("tmr:///" + Vars.comport.ToLower()))
         {
             reader.Connect();
             TagOp tagOp = new Gen2.WriteData(Gen2.Bank.RESERVED, byteIndex, data);
             SimpleReadPlan plan = new SimpleReadPlan(null, TagProtocol.GEN2, null, tagOp, 1000);
             reader.ParamSet("/reader/read/plan", plan);
             reader.ExecuteTagOp(tagOp, tagData);
         }
         DateTime timeAfterRead = DateTime.Now;
         TimeSpan timeElapsed = timeAfterRead - timeBeforeRead;
         commandTotalTimeTextBox.Text = timeElapsed.TotalSeconds.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        static void Main(string[] args)
        {
            // Program setup
            if (1 != args.Length)
            {
                Console.WriteLine(String.Join("\r\n", new string[] {
                    "Please provide reader URL, such as:",
                    "tmr:///com4",
                    "tmr://my-reader.example.com",
                }));
                Environment.Exit(1);
            }

            try
            {
                // Create Reader object, connecting to physical device.
                // Wrap reader in a "using" block to get automatic
                // 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();
                    if ((r is SerialReader) || (r is LlrpReader))
                    {
                        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();
                        }
                            else
                            {
                                r.ParamSet("/reader/region/id", supportedRegions[0]);
                            }
                        }
                        Gen2.Password pass = new Gen2.Password(0x0);
                        r.ParamSet("/reader/gen2/accessPassword", pass);


                        // BlockWrite and read using ExecuteTagOp

                        Gen2.BlockWrite blockwrite = new Gen2.BlockWrite(Gen2.Bank.USER, 0, new ushort[] { 0xFFF1, 0x1122 });
                        r.ExecuteTagOp(blockwrite, null);

                        Gen2.ReadData read = new Gen2.ReadData(Gen2.Bank.USER, 0, 2);
                        ushort[] readData = (ushort[])r.ExecuteTagOp(read, null);

                        foreach (ushort word in readData)
                        {
                            Console.Write(String.Format(" {0:X4}", word));
                        }
                        Console.WriteLine();


                        // BlockWrite and read using embedded read command

                        SimpleReadPlan readplan;
                        TagReadData[] tagreads;

                        blockwrite = new Gen2.BlockWrite(Gen2.Bank.USER, 0, new ushort[] { 0x1234, 0x5678 });
                        readplan = new SimpleReadPlan(null, TagProtocol.GEN2,
                            //null,
                            new TagData("1234567890ABCDEF"),
                            blockwrite, 0);
                        r.ParamSet("/reader/read/plan", readplan);
                        r.Read(500);

                        readplan = new SimpleReadPlan(null, TagProtocol.GEN2,
                            null,
                            new Gen2.ReadData(Gen2.Bank.USER, 0, 2),
                            0);
                        r.ParamSet("/reader/read/plan", readplan);
                        tagreads = r.Read(500);
                        foreach (TagReadData trd in tagreads)
                        {
                            foreach (byte b in trd.Data)
                            {
                                Console.Write(String.Format(" {0:X2}", b));
                            }

                            Console.WriteLine("    " + trd.ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error: This codelet works only for Serial Readers and Llrp Readers");
                    }
                }
            }
            catch (ReaderException re)
            {
                Console.WriteLine("Error: " + re.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
        /// <summary>
        /// Execute embedded tag operations
        /// </summary>
        /// <param name="filter"> filter </param>
        /// <param name="isFastSearch"> fast search enable</param>
        private void EmbeddedTagOpFilter(TagFilter filter, bool isFastSearch)
        {
            TagReadData[] tagReads = null;
            SimpleReadPlan readPlan = null;
            try
            {
                //ActivateSecureMode tag operation
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpActivateSecureMode, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpActivateSecureMode, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("Activate secure mode tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //AuthenticateOBU tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpAuthenticateOBU, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpAuthenticateOBU, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("AuthenticateOBU tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //ActivateSiniavMode tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpActivateSiniavMode, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpActivateSiniavMode, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("Activate siniav mode tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //OBUAuthFullPass1 tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUAuthFullPass1, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUAuthFullPass1, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("OBUAuthFullPass1 tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //OBUAuthFullPass2 tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUAuthFullPass2, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUAuthFullPass2, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("OBUAuthFullPass2 tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //OBUAuthID tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUAuthID, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUAuthID, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("OBUAuthID tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //OBUReadFromMemMap tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUReadFromMemMap, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUReadFromMemMap, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("OBUReadFromMemMap tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //OBUWriteToMemMap tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUWriteToMemMap, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUWriteToMemMap, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("OBUWriteToMemMap tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //OBUAuthFullPass tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUAuthFullPass, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpOBUAuthFullPass, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("OBUAuthFullPass tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //GetTokenId tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpGetTokenId, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpGetTokenId, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("GetTokenId tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //ReadSec tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpReadSec, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpReadSec, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("ReadSec tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();

                //WriteSec tag operation
                tagReads = null;
                readPlan = null;
                if (!isFastSearch)
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpWriteSec, 10);
                }
                else
                {
                    readPlan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, tagOpWriteSec, isFastSearch, 10);
                    Console.WriteLine("Fast search enable : " + isFastSearch.ToString());
                }
                reader.ParamSet("/reader/read/plan", readPlan);
                Console.WriteLine("Read Plan : " + readPlan.ToString());
                tagReads = reader.Read(1000);
                Console.WriteLine("WriteSec tag operation : ");
                foreach (TagReadData tr in tagReads)
                {
                    Console.WriteLine("Data : {0}", ByteFormat.ToHex(tr.Data));
                    Console.WriteLine("Data length : " + tr.Data.Length);
                }
                Console.WriteLine();
            }
            catch (ReaderException re)
            {
                throw re;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
 private void PerformReadAllMemOperation(TagFilter filter, TagOp op)
 {
     TagReadData[] tagReads = null;
     SimpleReadPlan plan = new SimpleReadPlan(null, TagProtocol.GEN2, filter, op, 1000);
     reader.ParamSet("/reader/read/plan", plan);
     Console.WriteLine("Embedded tag operation - ");
     // Read tags
     tagReads = reader.Read(500);
     foreach (TagReadData tr in tagReads)
     {
         Console.WriteLine(tr.ToString());
         if (0 < tr.Data.Length)
         {
             Console.WriteLine(" Embedded read data: " + ByteFormat.ToHex(tr.Data, "", " "));
             Console.WriteLine(" User memory: " + ByteFormat.ToHex(tr.USERMemData, "", " "));
             Console.WriteLine(" Reserved memory: " + ByteFormat.ToHex(tr.RESERVEDMemData, "", " "));
             Console.WriteLine(" Tid memory: " + ByteFormat.ToHex(tr.TIDMemData, "", " "));
             Console.WriteLine(" EPC memory: " + ByteFormat.ToHex(tr.EPCMemData, "", " "));
         }
         Console.WriteLine(" Embedded read data length:" + tr.Data.Length);
     }
     Console.WriteLine();
     Console.WriteLine("Standalone tag operation - ");
     ushort[] data = (ushort[])reader.ExecuteTagOp(op, filter);
     //// Print tag reads
     if (0 < data.Length)
     {
         Console.WriteLine(" Standalone read data:" + ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(data), "", " "));
         Console.WriteLine(" Standalone read data length:" + ByteConv.ConvertFromUshortArray(data).Length);
     }
     data = null;
     Console.WriteLine();
 }
        private void SetReadPlan()
        {
           
            TagFilter filter = null;


            if (selectMemBank == Gen2.Bank.EPC) 
            {
                if (txtEpc.Text != "")
                {
                    filter = new TagData(txtEpc.Text);
                }
            }
            else
            {
                byte[] data = ByteFormat.FromHex(txtData.Text);

                if (null == data)
                {
                    dataLength = 0;
                }
                else
                {
                    dataLength = data.Length;
                }

                filter = new Gen2.Select(false, selectMemBank, Convert.ToUInt16(startAddress * 16), Convert.ToUInt16(dataLength * 8), data);
            }
            
            SimpleReadPlan srp = new SimpleReadPlan(new int[]{antenna}, TagProtocol.GEN2, filter, 1000);
            objReader.ParamSet("/reader/read/plan", srp);
        }
Beispiel #21
0
        private void btnConnect_Click(object sender, EventArgs e)
        {

            try
            {
                if (btnConnect.Text.Equals("Connect"))
                {
                    String model = string.Empty;
                    string readeruri = comboBox1.SelectedItem.ToString();
                    objReader = Reader.Create(string.Concat("eapi:///", readeruri));
                    objReader.Connect();
                    model = (string)objReader.ParamGet("/reader/version/model");
                    Reader.Region regionToSet = (Reader.Region)objReader.ParamGet("/reader/region/id");
                    if (objReader is SerialReader)
                    {
                        if (regionToSet == Reader.Region.UNSPEC)
                        {
                            if (model.Equals("M6e PRC"))
                            {
                                regionToSet = Reader.Region.PRC;
                            }
                            else
                            {
                                regionToSet = Reader.Region.NA;
                            }
                        }
                    }
                    objReader.ParamSet("/reader/region/id", regionToSet);

                    if (model.Equals("M6e Micro"))
                    {
                        SimpleReadPlan plan = new SimpleReadPlan(new int[] { 1, 2 }, TagProtocol.GEN2);
                        objReader.ParamSet("/reader/read/plan", plan);
                    }
                    btnConnect.Text = "Disconnect";
                    btnReadOnce.Enabled = true;
                    comboBox1.Enabled = false;
                    btnRefresh.Enabled = false;
                    lblReadTimeout.Enabled = true;
                    tbxReadTimeout.Enabled = true;
                    UpdateGrid();
                }
                else
                {
                    objReader.Destroy();
                    objReader = null;
                    btnReadOnce.Enabled = false;
                    comboBox1.Enabled = true;
                    lblReadTimeout.Enabled = false;
                    tbxReadTimeout.Enabled = false;
                    btnConnect.Text = "Connect";
                    btnRefresh.Enabled = true;
                    lblTotalTagCount.Text = "0";
                    lblUniqueTagCount.Text = "0";
                }
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message, "Error");
                objReader.Destroy();
                objReader = null;
                btnReadOnce.Enabled = false;
                btnConnect.Text = "Connect";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Reader message");
            }

        }
Beispiel #22
0
        public ReadPlan LoadSimpleReadPlan(string valstr)
        {
            Object value = ParseValue(valstr);
            string str   = string.Empty;

            //Reamoves leading string for ex: SimpleReadPlan:
            str = valstr.Remove(0, 15);
            SimpleReadPlan srp = new SimpleReadPlan();
            //Regular expression to remove leading and trailing square brackets
            string remove = Regex.Replace(str, @"]$|^\[", "");

            //Regular expression to split the string
            string[]  lines = Regex.Split(remove, @",(?![^\[\]]*\])");
            TagFilter tf    = null;
            TagOp     op    = null;

            foreach (string line in lines)
            {
                if (-1 != line.IndexOf("Antennas"))
                {
                    ArrayList list    = new ArrayList();
                    int[]     antList = null;
                    object    value1  = ParseValue(line.Split('=')[1]);
                    if (value1 != null)
                    {
                        antList = (int[])((ArrayList)value1).ToArray(typeof(int));
                    }
                    srp.Antennas = antList;
                }
                else if (-1 != line.IndexOf("Protocol"))
                {
                    srp.Protocol = (TagProtocol)Enum.Parse(typeof(TagProtocol), line.Split('=')[1], true);
                }
                else if (-1 != line.IndexOf("Filter"))
                {
                    string filterData = line.Split('=')[1];
                    if (-1 != filterData.IndexOf("Gen2.Select"))
                    {
                        str = line.Remove(0, 19);
                        //Regular expression to remove leading and trailing square brackets
                        str = Regex.Replace(str, @"]$|^\[", "");
                        //Regular expression to split the string
                        string[]  select     = Regex.Split(str, @"[ ,;]+");
                        bool      Invert     = false;
                        Gen2.Bank bank       = Gen2.Bank.EPC;
                        uint      BitPointer = 0;
                        ushort    BitLength  = 0;
                        byte[]    mask       = null;
                        if (select.Length != 5)
                        {
                            throw new Exception("Invalid number of arguments for ReadPlan filter");
                        }
                        foreach (string arg in select)
                        {
                            if (-1 != arg.IndexOf("Invert"))
                            {
                                Invert = Convert.ToBoolean(arg.Split('=')[1]);
                            }
                            else if (-1 != arg.IndexOf("Bank"))
                            {
                                bank = (Gen2.Bank)Enum.Parse(typeof(Gen2.Bank), arg.Split('=')[1], true);
                            }
                            else if (-1 != arg.IndexOf("BitPointer"))
                            {
                                BitPointer = Convert.ToUInt32(arg.Split('=')[1]);
                            }
                            else if (-1 != arg.IndexOf("BitLength"))
                            {
                                BitLength = Convert.ToUInt16(arg.Split('=')[1]);
                            }
                            else if (-1 != arg.IndexOf("Mask"))
                            {
                                mask = StringToByteArray(arg.Split('=')[1]);
                            }
                            else
                            {
                                throw new Exception("Invalid Argument in ReadPlan");
                            }
                        }
                        tf = new Gen2.Select(Invert, bank, BitPointer, BitLength, mask);
                    }
                    else if (-1 != filterData.IndexOf("EPC"))
                    {
                        str = line.Remove(0, 15);
                        str = Regex.Replace(str, @"]$|^\[", "");
                        tf  = new TagData(StringToByteArray((str.Split('=')[1])));
                    }
                    else
                    {
                        if (!filterData.Equals("null"))
                        {
                            throw new Exception("Invalid Argument in ReadPlan");
                        }
                    }
                }
                else if (-1 != line.IndexOf("Op"))
                {
                    string tagOpData = line.Split('=')[1];
                    if (tagOpData != null)
                    {
                        if (-1 != tagOpData.IndexOf("ReadData"))
                        {
                            str = line.Remove(0, 12);
                            //Regular expression to remove leading and trailing square brackets
                            str = Regex.Replace(str, @"]$|^\[", "");
                            //Regular expression to split the string
                            string[]  select      = Regex.Split(str, @"[ ,;]+");
                            Gen2.Bank bank        = Gen2.Bank.EPC;
                            uint      wordAddress = 0;
                            byte      length      = 0;
                            foreach (string arg in select)
                            {
                                if (-1 != arg.IndexOf("Bank"))
                                {
                                    bank = (Gen2.Bank)Enum.Parse(typeof(Gen2.Bank), arg.Split('=')[1], true);
                                }
                                else if (-1 != arg.IndexOf("WordAddress"))
                                {
                                    wordAddress = Convert.ToUInt32(arg.Split('=')[1]);
                                }
                                else if (-1 != arg.IndexOf("Len"))
                                {
                                    length = Convert.ToByte(arg.Split('=')[1]);
                                }
                                else
                                {
                                    throw new Exception("Invalid Argument in ReadPlan TagOp");
                                }
                            }
                            op = new Gen2.ReadData(bank, wordAddress, length);
                        }
                        else
                        {
                            if (!tagOpData.Equals("null"))
                            {
                                throw new Exception("Invalid Argument in ReadPlan");
                            }
                        }
                    }
                }
                else if (-1 != line.IndexOf("UseFastSearch"))
                {
                    srp.UseFastSearch = Convert.ToBoolean(line.Split('=')[1]);
                }
                else if (-1 != line.IndexOf("Weight"))
                {
                    srp.Weight = Convert.ToInt32(lines[5].Split('=')[1]);
                }
                else
                {
                    throw new Exception("Invalid Argument in ReadPlan");
                }
            }
            srp.Filter = tf;
            srp.Op     = op;
            return(srp);
        }