static void Main(string[] args) { // Program setup if (args.Length != 1) { Console.WriteLine("Please provide reader URL, such as:\n" + "tmr:///com4\n" + "tmr://my-reader.example.com\n"); Environment.Exit(1); } // Create Reader object, connecting to physical device try { Reader r; TagReadData[] tagReads, filteredTagReads; TagFilter filter; 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]); } } // In the current system, sequences of Gen2 operations require Session 0, // since each operation resingulates the tag. In other sessions, // the tag will still be "asleep" from the preceding singulation. Gen2.Session oldSession = (Gen2.Session)r.ParamGet("/reader/gen2/session"); Gen2.Session newSession = Gen2.Session.S0; Console.WriteLine("Changing to Session "+newSession+" (from Session "+oldSession+")"); r.ParamSet("/reader/gen2/session", newSession); Console.WriteLine(); try { Console.WriteLine("Unfiltered Read:"); // Read the tags in the field tagReads = r.Read(500); foreach (TagReadData tr in tagReads) Console.WriteLine(tr.ToString()); Console.WriteLine(); if (0 == tagReads.Length) { Console.WriteLine("No tags found."); } else { // A TagData object may be used as a filter, for example to // perform a tag data operation on a particular tag. Console.WriteLine("Filtered Tagop:"); // Read kill password of tag found in previous operation filter = tagReads[0].Tag; Console.WriteLine("Read kill password of tag {0}", filter); Gen2.ReadData tagop = new Gen2.ReadData(Gen2.Bank.RESERVED, 0, 2); try { ushort[] data = (ushort[])r.ExecuteTagOp(tagop, filter); foreach (ushort word in data) { Console.Write("{0:X4}", word); } Console.WriteLine(); } catch (ReaderException ex) { Console.WriteLine("Can't read tag: {0}", ex.Message); } Console.WriteLine(); // Filter objects that apply to multiple tags are most useful in // narrowing the set of tags that will be read. This is // performed by setting a read plan that contains a filter. // A TagData with a short EPC will filter for tags whose EPC // starts with the same sequence. filter = new TagData(tagReads[0].Tag.EpcString.Substring(0, 4)); Console.WriteLine("EPCs that begin with {0}:", filter); r.ParamSet("/reader/read/plan", new SimpleReadPlan(null, TagProtocol.GEN2, filter, 1000)); filteredTagReads = r.Read(500); foreach (TagReadData tr in filteredTagReads) Console.WriteLine(tr.ToString()); Console.WriteLine(); // A filter can also be an full Gen2 Select operation. For // example, this filter matches all Gen2 tags where bits 8-19 of // the TID are 0x003 (that is, tags manufactured by Alien // Technology). Console.WriteLine("Tags with Alien Technology TID"); filter = new Gen2.Select(false, Gen2.Bank.TID, 8, 12, new byte[] { 0, 0x30 }); r.ParamSet("/reader/read/plan", new SimpleReadPlan(null, TagProtocol.GEN2, filter, 1000)); filteredTagReads = r.Read(500); foreach (TagReadData tr in filteredTagReads) Console.WriteLine(tr.ToString()); Console.WriteLine(); // Gen2 Select may also be inverted, to give all non-matching tags Console.WriteLine("Tags without Alien Technology TID"); filter = new Gen2.Select(true, Gen2.Bank.TID, 8, 12, new byte[] { 0, 0x30 }); r.ParamSet("/reader/read/plan", new SimpleReadPlan(null, TagProtocol.GEN2, filter, 1000)); filteredTagReads = r.Read(500); foreach (TagReadData tr in filteredTagReads) Console.WriteLine(tr.ToString()); Console.WriteLine(); // Filters can also be used to match tags that have already been // read. This form can only match on the EPC, as that's the only // data from the tag's memory that is contained in a TagData // object. // Note that this filter has invert=true. This filter will match // tags whose bits do not match the selection mask. // Also note the offset - the EPC code starts at bit 32 of the // EPC memory bank, after the StoredCRC and StoredPC. filter = new Gen2.Select(true, Gen2.Bank.EPC, 32, 2, new byte[] { (byte)0xC0 }); Console.WriteLine("EPCs with first 2 bits equal to zero (post-filtered):"); foreach (TagReadData tr in tagReads) // unfiltered tag reads from the first example if (filter.Matches(tr.Tag)) Console.WriteLine(tr.ToString()); Console.WriteLine(); } } finally { // Restore original settings Console.WriteLine("Restoring Session " + oldSession); r.ParamSet("/reader/gen2/session", oldSession); } // Shut down reader r.Destroy(); } catch (ReaderException re) { Console.WriteLine("Error: " + re.ToString()); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }
private void PopulateData() { try { Mouse.SetCursor(Cursors.Wait); // Create the object to read tag memory ReadTagMemory readTagMem = new ReadTagMemory(objReader, model); if ((bool)rbFirstTagIns.IsChecked) { antenna = GetSelectedAntennaList()[0]; } objReader.ParamSet("/reader/tagop/antenna", antenna); TagFilter searchSelect = null; if ((bool)rbSelectedTagIns.IsChecked) { if (lblSelectFilter.Content.ToString().Contains("EPC ID")) { searchSelect = new TagData(currentEPC); } else { int dataLength = 0; byte[] SearchSelectData = ByteFormat.FromHex(txtData.Text); if (null != SearchSelectData) { dataLength = SearchSelectData.Length; } searchSelect = new Gen2.Select(false, selectMemBank, Convert.ToUInt16(startAddress * 16), Convert.ToUInt16(dataLength * 8), SearchSelectData); } } else { searchSelect = new TagData(currentEPC); } #region ReadReservedMemory //Read Reserved memory bank data ushort[] reservedData = null; txtKillPassword.Text = ""; txtAcessPassword.Text = ""; txtReservedMemUnusedValue.Text = ""; // Hide additional memory textboxes lblAdditionalReservedMem.Visibility = System.Windows.Visibility.Collapsed; txtReservedMemUnusedValue.Visibility = System.Windows.Visibility.Collapsed; lblAdditionalReservedMemAdd.Visibility = System.Windows.Visibility.Collapsed; try { readTagMem.ReadTagMemoryData(Gen2.Bank.RESERVED, searchSelect, ref reservedData); // Parse the response to get access pwd, kill pwd and if additional memory exists ParseReservedMemData(reservedData); } catch (Exception ex) { // Hide additional memory textboxes lblAdditionalReservedMem.Visibility = System.Windows.Visibility.Collapsed; txtReservedMemUnusedValue.Visibility = System.Windows.Visibility.Collapsed; lblAdditionalReservedMemAdd.Visibility = System.Windows.Visibility.Collapsed; txtReservedMemUnusedValue.Text = ""; // If either of the memory is locked get in or else throw the exception. if ((ex is FAULT_PROTOCOL_BIT_DECODING_FAILED_Exception) || (ex is FAULT_GEN2_PROTOCOL_MEMORY_LOCKED_Exception)) { try { ReadReservedMemData(Gen2.Bank.RESERVED, searchSelect); } catch (Exception e) { txtKillPassword.Text = e.Message; txtAcessPassword.Text = e.Message; } } else if (ex is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception) { txtKillPassword.Text = "Read Error"; txtAcessPassword.Text = "Read Error"; } else { txtKillPassword.Text = ex.Message; txtAcessPassword.Text = ex.Message; } } #endregion ReadReservedMemory #region ReadEPCMemory //Read EPC bank data ushort[] epcData = null; txtPC.Text = ""; txtCRC.Text = ""; txtEPCData.Text = ""; txtEPCValue.Text = ""; txtEPCUnused.Text = ""; txtEPCUnusedValue.Text = ""; txtadditionalMemValue.Text = ""; // Hide additional memory spUnused.Visibility = System.Windows.Visibility.Collapsed; spXPC.Visibility = System.Windows.Visibility.Collapsed; spXPC2.Visibility = System.Windows.Visibility.Collapsed; spAddMemory.Visibility = System.Windows.Visibility.Collapsed; try { readTagMem.ReadTagMemoryData(Gen2.Bank.EPC, searchSelect, ref epcData); ParseEPCMemData(epcData, searchSelect); } catch (Exception ex) { txtEPCData.Text = ex.Message; rbEPCAscii.IsEnabled = false; rbEPCBase36.IsEnabled = false; } #endregion ReadEPCMemory #region ReadTIDMemory //Read TID bank data ushort[] tidData = null; txtClsID.Text = ""; txtVendorID.Text = ""; txtVendorValue.Text = ""; txtModelID.Text = ""; txtModeldIDValue.Text = ""; txtUniqueIDValue.Text = ""; try { readTagMem.ReadTagMemoryData(Gen2.Bank.TID, searchSelect, ref tidData); ParseTIDMemData(tidData); } catch (Exception ex) { if (ex is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception) { txtUniqueIDValue.Text = "Read Error"; } else { txtUniqueIDValue.Text = ex.Message; } } #endregion ReadTIDMemory #region ReadUserMemory //Read USER bank data ushort[] userMemData = null; txtUserDataValue.Text = ""; txtUserMemData.Text = ""; try { readTagMem.ReadTagMemoryData(Gen2.Bank.USER, searchSelect, ref userMemData); ParseUserMemData(userMemData); } catch (Exception ex) { if (ex is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception) { txtUserMemData.Text = "Read Error"; } else { txtUserMemData.Text = ex.Message; } } #endregion ReadUserMemory } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Mouse.SetCursor(Cursors.Arrow); } }
/// <summary> /// Populate access password of the tag /// </summary> private void PopulateUserData() { try { // Clear the previous error ResetLockActionCheckBoxes(); grpbxLockTgAccessPwd.IsEnabled = true; Mouse.SetCursor(Cursors.Wait); if ((bool)rbFirstTagLockTagTb.IsChecked) { antenna = GetSelectedAntennaList()[0]; } objReader.ParamSet("/reader/tagop/antenna", antenna); TagFilter searchSelect = null; if ((bool)rbSelectedTagLockTagTb.IsChecked) { if (lblSelectFilter.Content.ToString().Contains("EPC ID")) { searchSelect = new TagData(currentEPC); } else { int dataLength = 0; byte[] SearchSelectData = ByteFormat.FromHex(txtData.Text); if (null != SearchSelectData) { dataLength = SearchSelectData.Length; } searchSelect = new Gen2.Select(false, selectMemBank, Convert.ToUInt16(accessPwddStartAddress * 16), Convert.ToUInt16(dataLength * 8), SearchSelectData); } } else { searchSelect = new TagData(currentEPC); } //Read Reserved memory bank data TagOp op; ushort[] reservedData = null; txtbxAccesspaasword.Text = ""; try { string reservedBankData = string.Empty; if (model.Equals("M5e") || model.Equals("M5e EU") || model.Equals("M5e Compact") || model.Equals("Astra")) { ReadData(Gen2.Bank.RESERVED, searchSelect, out reservedData); } else { op = new Gen2.ReadData(Gen2.Bank.RESERVED, 2, 0); reservedData = (ushort[])objReader.ExecuteTagOp(op, searchSelect); } if (null != reservedData) reservedBankData = ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(reservedData), "", " "); txtbxAccesspaasword.Text = reservedBankData.Trim(' '); grpbxLockTgApplyLocks.IsEnabled = true; grpbxLockTgLockActns.IsEnabled = true; btnWriteAccessPwd.IsEnabled = true; } catch (Exception ex) { // Show the error in access password section if failed txtblkErrorAccessPassword.Visibility = System.Windows.Visibility.Visible; grpbxLockTgApplyLocks.IsEnabled = false; grpbxLockTgLockActns.IsEnabled = false; btnWriteAccessPwd.IsEnabled = false; if (ex is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception) { txtblkErrorAccessPassword.Text = "Error: Read Error"; } else if (ex is FAULT_GEN2_PROTOCOL_MEMORY_LOCKED_Exception) { txtblkErrorAccessPassword.Text = "Error: Could not read access password. Access Password may be locked. You must enter the correct Access Password to proceed with locking"; } else { txtblkErrorAccessPassword.Text = "Error: "+ex.Message; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Mouse.SetCursor(Cursors.Arrow); } }
private void btnWriteAccessPwd_Click(object sender, RoutedEventArgs e) { try { Mouse.SetCursor(Cursors.Wait); if (txtbxAccesspaasword.Text.Length <= 0) { MessageBox.Show("Access password can't be empty", "Universal Reader Assistant", MessageBoxButton.OK, MessageBoxImage.Information); return; } if ((bool)rbFirstTagLockTagTb.IsChecked) { antenna = ((null != GetSelectedAntennaList()) ? (GetSelectedAntennaList()[0]) : antenna); } objReader.ParamSet("/reader/tagop/antenna", antenna); if ((bool)rbSelectedTagLockTagTb.IsChecked) { TagFilter searchSelect = null; if (selectMemBank == Gen2.Bank.EPC) { searchSelect = new TagData(txtEpc.Text); } else { byte[] SearchSelectData = ByteFormat.FromHex(txtData.Text); if (null == SearchSelectData) { dataLength = 0; } else { dataLength = SearchSelectData.Length; } searchSelect = new Gen2.Select(false, selectMemBank, Convert.ToUInt16(accessPwddStartAddress * 16), Convert.ToUInt16(dataLength * 8), SearchSelectData); } WriteAccessPassword(searchSelect); } else { WriteAccessPassword(null); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Mouse.SetCursor(Cursors.Arrow); } }
private void btnApplyLockActions_Click(object sender, RoutedEventArgs e) { try { statusLockActions.Clear(); // Atleast one lock action need be selected to perform apply if (!(selectedLockActions.Count > 0)) { MessageBox.Show("Please select atleast one lock action to perform", "Universal Reader Assistant", MessageBoxButton.OK, MessageBoxImage.Information); return; } // Either of the lock/unlock need to be selected, if Permanent? is selected. if ((bool)chkbxPermaLockAccessPwd.IsChecked) { if (false == ((bool)chkbxLockAccessPwd.IsChecked || (bool)chkbxUnLocAccessPwd.IsChecked)) { MessageBox.Show("Read/Write Lock or UnLock need to be selected, if Permanent? for Access Password is checked", "Universal Reader Assistant", MessageBoxButton.OK, MessageBoxImage.Information); return; } } // Either of the lock/unlock need to be selected, if Permanent? is selected. if ((bool)chkbxPermaLockKillPwd.IsChecked) { if (false == ((bool)chkbxLockKillPwd.IsChecked || (bool)chkbxUnLockKillPwd.IsChecked)) { MessageBox.Show("Read/Write Lock or UnLock need to be selected, if Permanent? for Kill Password is checked", "Universal Reader Assistant", MessageBoxButton.OK, MessageBoxImage.Information); return; } } // Either of the lock/unlock need to be selected, if Permanent? is selected. if ((bool)chkbxPermaLockTIDMem.IsChecked) { if (false == ((bool)chkbxLockTIDMem.IsChecked || (bool)chkbxUnLockTIDMem.IsChecked)) { MessageBox.Show("Write Lock or UnLock need to be selected, if Permanent? for TID Memory is checked", "Universal Reader Assistant", MessageBoxButton.OK, MessageBoxImage.Information); return; } } // Either of the lock/unlock need to be selected, if Permanent? is selected. if ((bool)chkbxPermaLockUserMem.IsChecked) { if (false == ((bool)chkbxLockUserMem.IsChecked || (bool)chkbxUnLockUserMem.IsChecked)) { MessageBox.Show("Write Lock or UnLock need to be selected, if Permanent? for User Memory is checked", "Universal Reader Assistant", MessageBoxButton.OK, MessageBoxImage.Information); return; } } // Either of the lock/unlock need to be selected, if Permanent? is selected. if ((bool)chkbxPermaLockEPCMem.IsChecked) { if (false == ((bool)chkbxLockEPCMem.IsChecked || (bool)chkbxUnLockEPCMem.IsChecked)) { MessageBox.Show("Write Lock or UnLock need to be selected, if Permanent? for EPC Memory is checked", "Universal Reader Assistant", MessageBoxButton.OK, MessageBoxImage.Information); return; } } // Access password can't be empty if (txtbxAccesspaasword.Text.Length <= 0) { MessageBox.Show("Access password can't be empty", "Universal Reader Assistant", MessageBoxButton.OK, MessageBoxImage.Information); return; } // Locking the tag with zero access password provides no security if (ByteConv.ToU32(ByteFormat.FromHex(txtbxAccesspaasword.Text.Replace(" ", "")), 0) == 0) { MessageBoxResult result = MessageBox.Show("Locking with Access Password = 0 provides no security, memory will be fully accessible. Continue?", "Universal Reader Assistant", MessageBoxButton.OKCancel, MessageBoxImage.Information); if (result.Equals(MessageBoxResult.Cancel)) { return; } } List<string> temp = new List<string>(); temp = selectedLockActions.ToList<string>(); foreach (string lck in temp) { if (lck.Contains("_PERMALOCK")) { MessageBoxResult result = MessageBox.Show("Are you sure you want the locking action "+lck+" to be made Permanent?. This cannot be undone.", "Universal Reader Assistant", MessageBoxButton.OKCancel, MessageBoxImage.Information); if (result.Equals(MessageBoxResult.Cancel)) { selectedLockActions.Remove(lck); } } } if (selectedLockActions.Contains("Gen2.LockAction.ACCESS_LOCK") || selectedLockActions.Contains("Gen2.LockAction.ACCESS_PERMALOCK")) { SaveAccessPassword(); } Mouse.SetCursor(Cursors.Wait); if ((bool)rbFirstTagLockTagTb.IsChecked) { antenna = ((null != GetSelectedAntennaList()) ? (GetSelectedAntennaList()[0]) : antenna); } objReader.ParamSet("/reader/tagop/antenna", antenna); if ((bool)rbSelectedTagLockTagTb.IsChecked) { TagFilter searchSelect = null; if (selectMemBank == Gen2.Bank.EPC) { searchSelect = new TagData(txtEpc.Text); } else { byte[] SearchSelectData = ByteFormat.FromHex(txtData.Text); if (null == SearchSelectData) { dataLength = 0; } else { dataLength = SearchSelectData.Length; } searchSelect = new Gen2.Select(false, selectMemBank, Convert.ToUInt16(accessPwddStartAddress * 16), Convert.ToUInt16(dataLength * 8), SearchSelectData); } ApplyLock(searchSelect); } else { ApplyLock(null); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Mouse.SetCursor(Cursors.Arrow); } }
/// <summary> /// Current access password, epc and tid need to be saved before applying the lock on access password" /// </summary> private void SaveAccessPassword() { try { MessageBox.Show("Current access password need to be saved before applying the lock on Access Password","Universal Reader Assistant", MessageBoxButton.OK, MessageBoxImage.Information); string accessPwdSaveFileDialogFileName = "AccessPwd"; SaveFileDialog accessPwdSaveFileDialog = new SaveFileDialog(); accessPwdSaveFileDialog.Filter = "Text Files (.txt)|*.txt"; accessPwdSaveFileDialog.FileName = accessPwdSaveFileDialogFileName; if ((bool)accessPwdSaveFileDialog.ShowDialog()) { accessPwdSaveFileDialogFileName = accessPwdSaveFileDialog.FileName; TextWriter txtWriter = new StreamWriter(accessPwdSaveFileDialogFileName); StringBuilder stringAccesspAssword = new StringBuilder(); Mouse.SetCursor(Cursors.Wait); if ((bool)rbFirstTagLockTagTb.IsChecked) { antenna = GetSelectedAntennaList()[0]; } objReader.ParamSet("/reader/tagop/antenna", antenna); TagFilter searchSelect = null; stringAccesspAssword.Append("EPC: "+currentEPC); stringAccesspAssword.Append(Environment.NewLine); if ((bool)rbSelectedTagLockTagTb.IsChecked) { if (lblSelectFilter.Content.ToString().Contains("EPC ID")) { searchSelect = new TagData(currentEPC); } else { int dataLength = 0; byte[] SearchSelectData = ByteFormat.FromHex(txtData.Text); if (null != SearchSelectData) { dataLength = SearchSelectData.Length; } searchSelect = new Gen2.Select(false, selectMemBank, Convert.ToUInt16(accessPwddStartAddress * 16), Convert.ToUInt16(dataLength * 8), SearchSelectData); } } else { searchSelect = new TagData(currentEPC); } //Read TID bank data ushort[] tidData = null; TagOp op; try { string tidBankData = string.Empty; if (model.Equals("M5e") || model.Equals("M5e EU") || model.Equals("M5e Compact") || model.Equals("Astra")) { ReadData(Gen2.Bank.TID, searchSelect, out tidData); } else { op = new Gen2.ReadData(Gen2.Bank.TID, 0, 0); tidData = (ushort[])objReader.ExecuteTagOp(op, searchSelect); } if (null != tidData) tidBankData = ByteFormat.ToHex(ByteConv.ConvertFromUshortArray(tidData), "", " "); if (tidBankData.Length > 0) { stringAccesspAssword.Append("TID: "+tidBankData.Replace(" ","")); } } catch (Exception ex) { if (ex is FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception) { stringAccesspAssword.Append("TID: Read Error"); } else { stringAccesspAssword.Append("TID: "+ex.Message); } } stringAccesspAssword.Append(Environment.NewLine); stringAccesspAssword.Append("AccessPassword: 0x"+txtbxAccesspaasword.Text.Replace(" ","")); stringAccesspAssword.Append(Environment.NewLine); txtWriter.WriteLine(stringAccesspAssword.ToString()); txtWriter.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Mouse.SetCursor(Cursors.Arrow); } }
private void btnWrite_Click(object sender, RoutedEventArgs e) { try { Mouse.SetCursor(Cursors.Wait); if ((bool)rbFirstTag.IsChecked) { antenna = ((null != GetSelectedAntennaList()) ? ( GetSelectedAntennaList()[0]) : antenna); } objReader.ParamSet("/reader/tagop/antenna", antenna); if ((bool)rbSelectedTag.IsChecked) { TagFilter searchSelect = null; if (lblSelectFilter.Content.ToString().Contains("EPC ID")) { searchSelect = new TagData(txtEpc.Text); } else { byte[] SearchSelectData = ByteFormat.FromHex(txtData.Text); if (null == SearchSelectData) { dataLength = 0; } else { dataLength = SearchSelectData.Length; } searchSelect = new Gen2.Select(false, selectMemBank, Convert.ToUInt16(startAddress * 16), Convert.ToUInt16(dataLength * 8), SearchSelectData); } WriteEPC(searchSelect, txtWriteEPC.Text); } else { WriteEPC(null, txtWriteEPC.Text); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Mouse.SetCursor(Cursors.Arrow); } }
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); }
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]); } } DenatranIAVCustomTagOperations denatranIavCustomTagOp = new DenatranIAVCustomTagOperations(); denatranIavCustomTagOp.reader = r; #region Initialsettings //Initial settings //Set BLF 320KHZ Console.WriteLine(String.Format("Get BLF : {0}", r.ParamGet("/reader/gen2/blf"))); Console.WriteLine("Set BLF to 320KHZ"); r.ParamSet("/reader/gen2/blf", Gen2.LinkFrequency.LINK320KHZ); Console.WriteLine(String.Format("Get BLF : {0}", r.ParamGet("/reader/gen2/blf"))); Console.WriteLine(); //Set session Console.WriteLine(String.Format("Get session : {0}", r.ParamGet("/reader/gen2/session"))); Console.WriteLine("Set session"); r.ParamSet("/reader/gen2/session", Gen2.Session.S0); Console.WriteLine(String.Format("Get session : {0}", r.ParamGet("/reader/gen2/session"))); Console.WriteLine(); //Set target Console.WriteLine(String.Format("Get target : {0}", r.ParamGet("/reader/gen2/target"))); Console.WriteLine("Set target"); r.ParamSet("/reader/gen2/target", Gen2.Target.AB); Console.WriteLine(String.Format("Get target : {0}", r.ParamGet("/reader/gen2/target"))); Console.WriteLine(); //Set tari Console.WriteLine(String.Format("Get tari : {0}", r.ParamGet("/reader/gen2/tari"))); Console.WriteLine("Set tari"); r.ParamSet("/reader/gen2/tari", Gen2.Tari.TARI_6_25US); Console.WriteLine(String.Format("Get tari : {0}", r.ParamGet("/reader/gen2/tari"))); Console.WriteLine(); //Set tagencoding Console.WriteLine(String.Format("Get tagencoding : {0}", r.ParamGet("/reader/gen2/tagEncoding"))); Console.WriteLine("Set tagencoding"); r.ParamSet("/reader/gen2/tagEncoding", Gen2.TagEncoding.FM0); Console.WriteLine(String.Format("Get tagencoding : {0}", r.ParamGet("/reader/gen2/tagEncoding"))); Console.WriteLine(); //Set Q Console.WriteLine(String.Format("Get Q : {0}", r.ParamGet("/reader/gen2/q"))); Console.WriteLine("Set Q"); Gen2.StaticQ staticQ = new Gen2.StaticQ(0); r.ParamSet("/reader/gen2/q", staticQ); Console.WriteLine(String.Format("Get Q : {0}", r.ParamGet("/reader/gen2/q"))); Console.WriteLine(); #endregion Initialsettings TagReadData[] tagReads; // Read tagReads = r.Read(500); if (tagReads.Length == 0) { Console.WriteLine("Error : No tags found"); } else { #region Filter initialization //Gen2Select filter Gen2.Select selectfilter = new Gen2.Select(false, Gen2.Bank.EPC, 32, (ushort)(tagReads[0].Epc.Length * 8), ByteFormat.FromHex(tagReads[0].EpcString)); //TagData filter TagFilter tagdataFilter = new TagData(ByteFormat.FromHex(tagReads[0].EpcString)); #endregion Filter initialization #region Tag Operation Initialization byte payload = 0x80; ushort readptr = 0xFFFF; ushort wordAddress = 0xFFFF; ushort word = 0xFFFF; //Read ptr for readsec tagop ushort readSecReadPtr = 0x0000; //Set the tag Identification and writeCredentials Gen2.DenatranIAVWriteCredential writeCredential = new Gen2.DenatranIAVWriteCredential ( new byte [] {0x80, 0x10, 0x00, 0x12, 0x34, 0xAD, 0xBD, 0xC0} , new byte [] {0xDE,0xAD,0xBE,0xEF,0xDE,0xAD,0xBE,0xEF,0xDE,0xAD,0xBE,0xEF,0xDE,0xAD,0xBE,0xEF}); //Set the data and writeCredentials for WriteSec Gen2.DenatranIAVWriteSecCredential writeSecCredential = new Gen2.DenatranIAVWriteSecCredential (new byte[] { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 }, new byte[] { 0x35, 0x49, 0x87, 0xbd, 0xb2, 0xab, 0xd2, 0x7c, 0x2e, 0x34, 0x78, 0x8b, 0xf2, 0xf7, 0x0b, 0xa2 }); //IAVDenatran secure tag operation - ActivateSecureMode denatranIavCustomTagOp.tagOpActivateSecureMode = new Gen2.Denatran.IAV.ActivateSecureMode(payload); //IAVDenatran secure tag operation - AuthenticateOBU denatranIavCustomTagOp.tagOpAuthenticateOBU = new Gen2.Denatran.IAV.AuthenticateOBU(payload); //IAVDenatran secure tag operation - ActivateSiniavMode denatranIavCustomTagOp.tagOpActivateSiniavMode = new Gen2.Denatran.IAV.ActivateSiniavMode(0x81, new byte[] { 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef }); //IAVDenatran secure tag operation - OBUAuthFullPass1 denatranIavCustomTagOp.tagOpOBUAuthFullPass1 = new Gen2.Denatran.IAV.OBUAuthFullPass1(payload); //IAVDenatran secure tag operation - OBUAuthFullPass2 denatranIavCustomTagOp.tagOpOBUAuthFullPass2 = new Gen2.Denatran.IAV.OBUAuthFullPass2(payload); //IAVDenatran secure tag operation - OBUAuthID denatranIavCustomTagOp.tagOpOBUAuthID = new Gen2.Denatran.IAV.OBUAuthID(payload); //IAVDenatran secure tag operation - OBUReadFromMemMap denatranIavCustomTagOp.tagOpOBUReadFromMemMap = new Gen2.Denatran.IAV.OBUReadFromMemMap (payload, readptr); //IAVDenatran secure tag operation - OBUWriteToMemMap denatranIavCustomTagOp.tagOpOBUWriteToMemMap = new Gen2.Denatran.IAV.OBUWriteToMemMap (payload, wordAddress, word, writeCredential); //IAVDenatran secure tag operation - OBUAuthFullPass denatranIavCustomTagOp.tagOpOBUAuthFullPass = new Gen2.Denatran.IAV.OBUAuthFullPass(payload); //IAVDenatran secure tag operation - GetTokenId denatranIavCustomTagOp.tagOpGetTokenId = new Gen2.Denatran.IAV.GetTokenId(); //IAVDenatran secure tag operation - ReadSec denatranIavCustomTagOp.tagOpReadSec = new Gen2.Denatran.IAV.ReadSec (payload, readSecReadPtr); //IAVDenatran secure tag operation - WriteSec denatranIavCustomTagOp.tagOpWriteSec = new Gen2.Denatran.IAV.WriteSec (payload, writeSecCredential); #endregion Tag Operation Initialization #region Standalonetagoperations //Standalone tagop Console.WriteLine("Standalone tagop without filter : "); Console.WriteLine(); denatranIavCustomTagOp.ExecuteTagOpFilter(null); Console.WriteLine("Standalone tagop with tagdata filter : "); Console.WriteLine(); denatranIavCustomTagOp.ExecuteTagOpFilter(tagdataFilter); Console.WriteLine("Standalone tagop with gen2Select filter : "); Console.WriteLine(); denatranIavCustomTagOp.ExecuteTagOpFilter(selectfilter); #endregion Standalonetagoperations #region Embeddedtagoperations //Embedded tagop Console.WriteLine("Embedded tagop without filter and fastsearch : "); Console.WriteLine(); denatranIavCustomTagOp.EmbeddedTagOpFilter(null, false); Console.WriteLine("Embedded tagop with tagdata filter and fastsearch enabled : "); Console.WriteLine(); denatranIavCustomTagOp.EmbeddedTagOpFilter(tagdataFilter, true); Console.WriteLine("Embedded tagop with gen2select filter and fast search enabled : "); Console.WriteLine(); denatranIavCustomTagOp.EmbeddedTagOpFilter(selectfilter, true); #endregion Embeddedtagoperations } } } catch (ReaderException re) { Console.WriteLine("Error: " + re.Message); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }
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); }
private static void TestMatchesFunc(Reader rdr, ArgParser pargs) { List<Gen2.TagData> list = new List<Gen2.TagData>(); list.Add(MakeGen2TagData("3000", "0x044D00000000040005010064", "CEDA")); list.Add(MakeGen2TagData("3000", "044D00000000040007010070", "7107")); list.Add(MakeGen2TagData("3000", "044D0000000004000701006E", "82F8")); list.Add(MakeGen2TagData("3000", "044D0000000004000401006B", "4981")); list.Add(MakeGen2TagData("3000", "044D0000000004000E01006C", "51CD")); list.Add(MakeGen2TagData("3000", "044D0000000004000601006D", "C42F")); list.Add(MakeGen2TagData("3000", "3028354D8202000000001A6B", "1119")); list.Add(MakeGen2TagData("3000", "050000000000000000003E61", "5911")); list.Add(MakeGen2TagData("3000", "C8399E480126DC040101006B", "E90C")); list.Add(MakeGen2TagData("3000", "2B3A27B0A182AF350101005C", "3548")); list.Add(MakeGen2TagData("3000", "88C10D7556FFCAB801010085", "87E8")); list.Add(MakeGen2TagData("3000", "050000000000000000003E62", "6972")); list.Add(MakeGen2TagData("3000", "D54F973EB39959DC0101007B", "A9D7")); list.Add(MakeGen2TagData("3000", "017DD52B43277B3B0101006A", "5E15")); list.Add(MakeGen2TagData("3000", "050000000000000000003E63", "7953")); list.Add(MakeGen2TagData("3000", "B4759AAAE63B8777010100DC", "1D17")); list.Add(MakeGen2TagData("3000", "48C4A2C790E52858020100A3", "D4FB")); list.Add(MakeGen2TagData("3000", "A726B70BA4B0566501010055", "3C5D")); list.Add(MakeGen2TagData("3000", "EA37F41943C9897901010098", "D187")); list.Add(MakeGen2TagData("3000", "A969352F11405A8001010080", "B69B")); list.Add(MakeGen2TagData("3000", "12BF6BAB28F2122801010079", "7201")); list.Add(MakeGen2TagData("3000", "F0581C70A5E07DF7010100B3", "1B3C")); list.Add(MakeGen2TagData("3000", "FE911EEF7B009548010100C2", "059C")); list.Add(MakeGen2TagData("3000", "7CDAAD120A073CE90101007A", "64FB")); list.Add(MakeGen2TagData("3000", "F1AA7950D9DCA7D6010100AF", "5DEA")); list.Add(MakeGen2TagData("3000", "7062721836BE7E9C010100C8", "CBBE")); list.Add(MakeGen2TagData("3000", "7F38863B16B4DE5501010050", "27CB")); list.Add(MakeGen2TagData("3000", "2D6FB358C2ED07960201004F", "F803")); list.Add(MakeGen2TagData("3000", "CC3797853CA8DB8102010058", "F117")); list.Add(MakeGen2TagData("3000", "7AF713E5D9ECD647020100B2", "BD94")); list.Add(MakeGen2TagData("3000", "069B3ED79043CBCE0101009A", "B18F")); list.Add(MakeGen2TagData("3000", "300833B2DDD9014035050000", "42E7")); list.Add(MakeGen2TagData("3000", "6EECABF073C4FD980101007C", "C2AE")); list.Add(MakeGen2TagData("3000", "349D9427086A289002010056", "C57B")); list.Add(MakeGen2TagData("3000", "D4E8CFB7D2D51C7F010100AB", "1250")); list.Add(MakeGen2TagData("3000", "69AE2A765487268601010099", "F8B9")); TestFilter("No Filter", null, list); Gen2.Select startsWithC = new Gen2.Select(false, Gen2.Bank.EPC, 32, 4, new byte[] { 0xC0 }); TestFilter("EPCs starting with C", startsWithC, list); Gen2.Select endsWith100xx = new Gen2.Select(false, Gen2.Bank.EPC, 32 + 96 - (5 * 4), 12, new byte[] { 0x10, 0x00 }); TestFilter("EPCs ending in 100xx", endsWith100xx, list); Gen2.Select doesntEndWith100xx = new Gen2.Select(true, Gen2.Bank.EPC, 32 + 96 - (5 * 4), 12, new byte[] { 0x10, 0x00 }); TestFilter("EPCs NOT ending in 100xx", doesntEndWith100xx, list); MultiFilter startsWithCAndEndsWith100xx = new MultiFilter(new TagFilter[] { startsWithC, endsWith100xx, }); TestFilter("EPCs starting with C AND ending in 100xx", startsWithCAndEndsWith100xx, list); TagData specificTag = new TagData("A726B70BA4B0566501010055"); TestFilter("Matches A726B70BA4B0566501010055", specificTag, list); }
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; } } }
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); } }