static void Main(string[] args) { // Program setup if (1 > args.Length) { Usage(); } TagFilter filter = null; for (int nextarg = 1; nextarg < args.Length; nextarg++) { string arg = args[nextarg]; if (arg.Equals("--ant")) { if (null != antennaList) { Console.WriteLine("Duplicate argument: --ant specified more than once"); Usage(); } antennaList = ParseAntennaList(args, nextarg); nextarg++; } else { Console.WriteLine("Argument {0}:\"{1}\" is not recognized", nextarg, arg); Usage(); } } try { // Create Reader object, connecting to physical device. // Wrap reader in a "using" block to get automatic // reader shutdown (using IDisposable interface). using (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(); } r.ParamSet("/reader/region/id", supportedRegions[0]); } if (r.isAntDetectEnabled(antennaList)) { Console.WriteLine("Module doesn't has antenna detection support please provide antenna list"); Usage(); } //Use first antenna for operation if (antennaList != null) { r.ParamSet("/reader/tagop/antenna", antennaList[0]); } // This select filter matches all Gen2 tags where bits 32-48 of the EPC are 0x0123 #if ENABLE_FILTER filter = new Gen2.Select(false, Gen2.Bank.EPC, 32, 16, new byte[] { 0x01, 0x23 }); #endif //Gen2.TagData epc = new Gen2.TagData(new byte[] { // 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, // 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, //}); //Gen2.WriteTag tagop = new Gen2.WriteTag(epc); //r.ExecuteTagOp(tagop, null); // Reads data from a tag memory bank after writing data to the requested memory bank without powering down of tag #if ENABLE_READ_AFTER_WRITE { //create a tagopList with write tagop followed by read tagop TagOpList tagopList = new TagOpList(); byte wordCount; ushort[] readData; //Write one word of data to USER memory and read back 8 words from EPC memory using WriteData and ReadData { ushort[] writeData = { 0x9999 }; wordCount = 8; Gen2.WriteData wData = new Gen2.WriteData(Gen2.Bank.USER, 2, writeData); Gen2.ReadData rData = new Gen2.ReadData(Gen2.Bank.EPC, 0, wordCount); //Gen2.WriteTag wTag = new Gen2.WriteTag(epc); // assemble tagops into list tagopList.list.Add(wData); tagopList.list.Add(rData); Console.WriteLine("###################Embedded Read after write######################"); // uncomment the following for embedded read after write. embeddedReadAfterWrite(null, tagopList); // call executeTagOp with list of tagops //readData = (ushort[])r.ExecuteTagOp(tagopList, null); //Console.WriteLine("ReadData: "); //foreach (ushort word in readData) //{ // Console.Write(" {0:X4}", word); //} //Console.WriteLine("\n"); } //clearing the list for next operation tagopList.list.Clear(); //Write 12 bytes(6 words) of EPC and read back 8 words from EPC memory using WriteTag and ReadData { Gen2.TagData epc1 = new Gen2.TagData(new byte[] { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, }); wordCount = 8; Gen2.WriteTag wtag = new Gen2.WriteTag(epc1); Gen2.ReadData rData = new Gen2.ReadData(Gen2.Bank.EPC, 0, wordCount); // assemble tagops into list tagopList.list.Add(wtag); tagopList.list.Add(rData); // call executeTagOp with list of tagops //readData = (ushort[])r.ExecuteTagOp(tagopList, null); //Console.WriteLine("ReadData: "); //foreach (ushort word in readData) //{ // Console.Write(" {0:X4}", word); //} //Console.WriteLine("\n"); } } #endif } } catch (ReaderException re) { Console.WriteLine("Error: " + re.Message); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }
// Octane API Methods ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // GUI Interactions /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void writeButton_Click(object sender, RoutedEventArgs e) { if (api == 1) { TagFilter filter = null; string epc = writeText.Text; var strs = Enumerable.Range(0, epc.Length / 2).Select(i => epc.Substring(i * 2, 2)); byte[] epcBytes = new byte[strs.ToString().Length]; if (hexRadio.IsChecked == true) { try { epcBytes = strs.Select(s => Convert.ToByte($"0x{s}", 16)).ToArray(); } catch (System.FormatException err) { reportText.Text = "No Tag Writes; Error: " + err.Message; reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; writeText.Focus(); } } else { try { char[] charValues = epc.ToCharArray(); string hexOutput = ""; foreach (char _eachChar in charValues) { // Get the integral value of the character. int value = Convert.ToInt32(_eachChar); // Convert the decimal value to a hexadecimal value in string form. hexOutput += String.Format("{0:X}", value); } var asciiStrs = Enumerable.Range(0, epc.Length).Select(i => hexOutput.Substring(i * 2, 2)); epcBytes = asciiStrs.Select(s => Convert.ToByte($"0x{s}", 16)).ToArray(); } catch (System.FormatException err) { reportText.Text = "No Tag Writes; Error: " + err.Message; reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; writeText.Focus(); } } Gen2.TagData epcData = new Gen2.TagData(epcBytes); Gen2.WriteTag tagOp; if (userRadioWrite.IsChecked == false) { tagOp = new Gen2.WriteTag(epcData); try { var success = writeJadakTag(JadakReader, filter, tagOp); if (success == true) { messageText = "Write Successful"; reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Green; writeText.Text = ""; writeText.Focus(); if (isDatabaseUsed == true) { var databaseSelector = int.Parse(databaseRecordText.Text) + 1; databaseRecordText.Text = databaseSelector.ToString(); updateExcelData(xlWorkSheet, databaseSelector); } } else { messageText = "No Tag Writes"; reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; writeText.Focus(); } } catch (FAULT_PROTOCOL_WRITE_FAILED_Exception ex) { System.Windows.MessageBox.Show("No Tag Writes, Please Scan Again; Error: " + ex.Message.ToString()); reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; } catch (FAULT_WRITE_PASSED_LOCK_FAILED_Exception ex) { System.Windows.MessageBox.Show("No Tag Writes, Please Scan Again; Error: " + ex.Message.ToString()); reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; } catch (FAULT_GEN2_PROTOCOL_MEMORY_LOCKED_Exception ex) { System.Windows.MessageBox.Show("No Tag Writes, Please Scan Again; Error: " + ex.Message.ToString()); reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; } catch (FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception ex) { System.Windows.MessageBox.Show("No Tag Writes, Please Scan Again; Error: " + ex.Message.ToString()); reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; } catch (FAULT_NO_TAGS_FOUND_Exception ex) { System.Windows.MessageBox.Show("No Tag Writes, Please Scan Again; Error: " + ex.Message.ToString()); reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; } } else { if (hexRadio.IsChecked == false) { try { char[] charValues = epc.ToCharArray(); string hexOutput = ""; foreach (char _eachChar in charValues) { // Get the integral value of the character. int value = Convert.ToInt32(_eachChar); // Convert the decimal value to a hexadecimal value in string form. hexOutput += String.Format("{0:X}", value); } var asciiStrs = Enumerable.Range(0, epc.Length).Select(i => hexOutput.Substring(i * 2, 2)); epcBytes = asciiStrs.Select(s => Convert.ToByte($"0x{s}", 16)).ToArray(); } catch (System.FormatException err) { reportText.Text = "No Tag Writes; Error: " + err.Message; reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; writeText.Focus(); } } ushort[] userData = new ushort[writeText.Text.Length]; int j; if (hexRadio.IsChecked == true) { j = userData.Length / 4; } else { j = userData.Length / 2; } if (BitConverter.IsLittleEndian) { Array.Reverse(epcBytes); } for (int i = 0; i < epcBytes.Length - 1; i = i + 2) { userData[j - 1] = BitConverter.ToUInt16(epcBytes, i); j--; } //var temp = userData[0]; //userData[0] = userData[1]; //userData[1] = temp; Gen2.WriteData tagOpUser = new Gen2.WriteData(Gen2.Bank.USER, 0, userData); try { var success = writeJadakTagUser(JadakReader, filter, tagOpUser); if (success == true) { messageText = "Write Successful"; reportText.Background = Brushes.Green; reportText.Text = "USER Write Successful: " + epc; writeText.Text = ""; writeText.Focus(); if (isDatabaseUsed == true) { var databaseSelector = int.Parse(databaseRecordText.Text) + 1; databaseRecordText.Text = databaseSelector.ToString(); updateExcelData(xlWorkSheet, databaseSelector); } } else { reportText.Text = "No Tag Writes"; reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; writeText.Focus(); } } catch (FAULT_PROTOCOL_WRITE_FAILED_Exception ex) { System.Windows.MessageBox.Show("No Tag Writes, Please Scan Again; Error: " + ex.Message.ToString()); reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; } catch (FAULT_WRITE_PASSED_LOCK_FAILED_Exception ex) { System.Windows.MessageBox.Show("No Tag Writes, Please Scan Again; Error: " + ex.Message.ToString()); reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; } catch (FAULT_GEN2_PROTOCOL_MEMORY_LOCKED_Exception ex) { System.Windows.MessageBox.Show("No Tag Writes, Please Scan Again; Error: " + ex.Message.ToString()); reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; } catch (FAULT_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC_Exception ex) { System.Windows.MessageBox.Show("No Tag Writes, Please Scan Again; Error: " + ex.Message.ToString()); reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; } catch (FAULT_NO_TAGS_FOUND_Exception ex) { System.Windows.MessageBox.Show("No Tag Writes, Please Scan Again; Error: " + ex.Message.ToString()); reportText.Background = Brushes.Yellow; System.Threading.Thread.Sleep(500); reportText.Background = Brushes.Red; //writeText.Text = ""; } catch (IndexOutOfRangeException exce) { reportText.Text = exce.Message.ToString(); } catch (ReaderException excep) { reportText.Text = excep.Message.ToString(); } } //check if tag is being locked if ((bool)lockRadioButton.IsChecked) { if (passwordText.Text.Length == 0) { System.Windows.MessageBox.Show("Please provide an Access Password to lock tags"); } else if (passwordText.Text.Length != 8) { System.Windows.MessageBox.Show("Access Password must be 8 characters in length"); } else { uint password = Convert.ToUInt32(passwordText.Text); string pass1 = passwordText.Text.Substring(0, 4); string pass2 = passwordText.Text.Substring(4, 4); ushort[] array = { Convert.ToUInt16(pass1), Convert.ToUInt16(pass2) }; Gen2.WriteData accessPWDTagOp = new Gen2.WriteData(Gen2.Bank.RESERVED, 2, array); Gen2.Lock lockTagOp = new Gen2.Lock(password, Gen2.LockAction.EPC_LOCK); try { JadakReader.ExecuteTagOp(accessPWDTagOp, null); JadakReader.ExecuteTagOp(lockTagOp, null); messageText = "Lock Successful"; } catch (ReaderException ex) { System.Windows.MessageBox.Show("Lock Tag failed; Error: " + ex.ToString()); } catch (Exception exc) { reportText.Text = exc.Message.ToString(); } } } //check if tag is being unlocked if (unlockRadioButton.IsChecked == true) { if (passwordText.Text.Length == 0) { System.Windows.MessageBox.Show("Please provide the Access Password to unlock tags"); } else if (passwordText.Text.Length != 8) { System.Windows.MessageBox.Show("Access Password must be 8 characters in length"); } else { uint password = Convert.ToUInt32(passwordText.Text); string pass1 = passwordText.Text.Substring(0, 4); string pass2 = passwordText.Text.Substring(4, 4); ushort[] array = { Convert.ToUInt16(pass1), Convert.ToUInt16(pass2) }; Gen2.WriteData accessPWDTagOp = new Gen2.WriteData(Gen2.Bank.RESERVED, 2, array); Gen2.Lock lockTagOp = new Gen2.Lock(password, Gen2.LockAction.EPC_UNLOCK); try { JadakReader.ExecuteTagOp(accessPWDTagOp, null); JadakReader.ExecuteTagOp(lockTagOp, null); messageText = "Unlock Successful"; } catch (ReaderException ex) { System.Windows.MessageBox.Show("Lock Tag failed; Error: " + ex.ToString()); } catch (Exception exc) { reportText.Text = exc.Message.ToString(); } } } } }
static void Main(string[] args) { // Program setup if (1 > args.Length) { Usage(); } for (int nextarg = 1; nextarg < args.Length; nextarg++) { string arg = args[nextarg]; if (arg.Equals("--ant")) { if (null != antennaList) { Console.WriteLine("Duplicate argument: --ant specified more than once"); Usage(); } antennaList = ParseAntennaList(args, nextarg); nextarg++; } else { Console.WriteLine("Argument {0}:\"{1}\" is not recognized", nextarg, arg); Usage(); } } try { // Create Reader object, connecting to physical device. // Wrap reader in a "using" block to get automatic // reader shutdown (using IDisposable interface). using (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(); } r.ParamSet("/reader/region/id", supportedRegions[0]); } string model = (string)r.ParamGet("/reader/version/model").ToString(); if (!model.Equals("M3e")) { if (r.isAntDetectEnabled(antennaList)) { Console.WriteLine("Module doesn't has antenna detection support please provide antenna list"); Usage(); } //Use first antenna for operation if (antennaList != null) { r.ParamSet("/reader/tagop/antenna", antennaList[0]); } } else { if (antennaList != null) { Console.WriteLine("Module doesn't support antenna input"); Usage(); } } // This select filter matches all Gen2 tags where bits 32-48 of the EPC are 0x0123 #if ENABLE_FILTER TagFilter filter = new Gen2.Select(false, Gen2.Bank.EPC, 32, 16, new byte[] { 0x01, 0x23 }); #endif if (!model.Equals("M3e")) { //Gen2.TagData epc = new Gen2.TagData(new byte[] { // 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, // 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, //}); //Gen2.WriteTag tagop = new Gen2.WriteTag(epc); //r.ExecuteTagOp(tagop, null); } // Reads data from a tag memory bank after writing data to the requested memory bank without powering down of tag #if ENABLE_READ_AFTER_WRITE { //create a tagopList with write tagop followed by read tagop TagOpList tagopList = new TagOpList(); byte wordCount; ushort[] readData; //Write one word of data to USER memory and read back 8 words from EPC memory using WriteData and ReadData { ushort[] writeData = { 0x9999 }; wordCount = 8; Gen2.WriteData wData = new Gen2.WriteData(Gen2.Bank.USER, 2, writeData); Gen2.ReadData rData = new Gen2.ReadData(Gen2.Bank.EPC, 0, wordCount); //Gen2.WriteTag wTag = new Gen2.WriteTag(epc); // assemble tagops into list tagopList.list.Add(wData); tagopList.list.Add(rData); Console.WriteLine("###################Embedded Read after write######################"); // uncomment the following for embedded read after write. embeddedRead(TagProtocol.GEN2, null, tagopList); // call executeTagOp with list of tagops //readData = (ushort[])r.ExecuteTagOp(tagopList, null); //Console.WriteLine("ReadData: "); //foreach (ushort word in readData) //{ // Console.Write(" {0:X4}", word); //} //Console.WriteLine("\n"); } //clearing the list for next operation tagopList.list.Clear(); //Write 12 bytes(6 words) of EPC and read back 8 words from EPC memory using WriteTag and ReadData { Gen2.TagData epc1 = new Gen2.TagData(new byte[] { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, }); wordCount = 8; Gen2.WriteTag wtag = new Gen2.WriteTag(epc1); Gen2.ReadData rData = new Gen2.ReadData(Gen2.Bank.EPC, 0, wordCount); // assemble tagops into list tagopList.list.Add(wtag); tagopList.list.Add(rData); // call executeTagOp with list of tagops //readData = (ushort[])r.ExecuteTagOp(tagopList, null); //Console.WriteLine("ReadData: "); //foreach (ushort word in readData) //{ // Console.Write(" {0:X4}", word); //} //Console.WriteLine("\n"); } } #endif // Perform read and print UID and tagtype of tag found SimpleReadPlan plan = new SimpleReadPlan(antennaList, TagProtocol.ISO15693, null, null, 1000); r.ParamSet("/reader/read/plan", plan); TagReadData[] tagReads = r.Read(1000); Console.WriteLine("UID: " + tagReads[0].EpcString); Console.WriteLine("TagType: " + (Iso15693.TagType)(tagReads[0].TagType)); MemoryType type; MultiFilter mulfilter = null; UInt32 address; byte length; #if ENABLE_M3E_FILTER //Initialize filter // Filters the tag based on tagtype TagFilter tagTypeFilter = new Select_TagType((UInt64)((Iso15693.TagType)(tagReads[0].TagType))); // Filters the tag based on UID TagFilter uidFilter = new Select_UID(32, ByteFormat.FromHex(tagReads[0].Tag.EpcString.Substring(0, 8))); // Initialize multi filter mulfilter = new MultiFilter(new TagFilter[] { tagTypeFilter, uidFilter }); #endif #if ENABLE_M3E_BLOCK_READ_WRITE //Initialize all the fields required for Read Data Tag operation type = MemoryType.BLOCK_MEMORY; address = 0; length = 1; // Read memory before write ReadMemory bRead = new ReadMemory(type, address, length); byte[] dataRead = (byte[])r.ExecuteTagOp(bRead, mulfilter); // prints the data read Console.WriteLine("Read Data before performing block write: "); foreach (byte i in dataRead) { Console.Write(" {0:X2}", i); } Console.WriteLine("\n"); // Uncomment this to enable Embedded read memory //embeddedRead(TagProtocol.ISO15693, mulfilter, bRead); // Initialize write memory byte[] data = new byte[] { 0x11, 0x22, 0x33, 0x44 }; WriteMemory writeOp = new WriteMemory(type, address, data); // Execute the tagop r.ExecuteTagOp(writeOp, mulfilter); // Uncomment this to enable Embedded write data //embeddedRead(TagProtocol.ISO15693, mulfilter, writeOp); //Read memory after block write ReadMemory readOp = new ReadMemory(type, address, length); byte[] readData = (byte[])r.ExecuteTagOp(readOp, mulfilter); // prints the data read Console.WriteLine("Read Data after performing block write operation: "); foreach (byte i in readData) { Console.Write(" {0:X2}", i); } Console.WriteLine("\n"); #endif #if ENABLE_M3E_SYSTEM_INFORMATION_MEMORY //Get the system information of tag. Address and length fields have no significance if memory type is BLOCK_SYSTEM_INFORMATION_MEMORY. type = MemoryType.BLOCK_SYSTEM_INFORMATION_MEMORY; address = 0; length = 0; ReadMemory sysInfoOp = new ReadMemory(type, address, length); byte[] systemInfo = (byte[])r.ExecuteTagOp(sysInfoOp, mulfilter); // parsing the system info response if (systemInfo.Length > 0) { parseGetSystemInfoResponse(systemInfo); } #endif #if ENABLE_M3E_SECURE_ID // Read secure id of tag. Address and length fields have no significance if memory type is SECURE_ID. type = MemoryType.SECURE_ID; address = 0; length = 0; ReadMemory secureIdOp = new ReadMemory(type, address, length); byte[] rspData = (byte[])r.ExecuteTagOp(secureIdOp, mulfilter); // parse secure id operation response. if (rspData.Length > 0) { parseSecureIdResponse(rspData); } #endif #if ENABLE_M3E_BLOCK_PROTECTION_STATUS // Get the block protection status of block 0. type = MemoryType.BLOCK_PROTECTION_STATUS_MEMORY; address = 0; length = 1; ReadMemory blkProtectionOp = new ReadMemory(type, address, length); byte[] statusData = (byte[])r.ExecuteTagOp(blkProtectionOp, mulfilter); // parse the block protection status response. if (statusData.Length == length) { parseGetBlockProtectionStatusResponse(statusData, address, length); } #endif } } catch (ReaderException re) { Console.WriteLine("Error: " + re.Message); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }
static void Main(string[] args) { bool enableFilter = false; TagFilter filter = null; // Program setup if (1 > args.Length) { Usage(); } for (int nextarg = 1; nextarg < args.Length; nextarg++) { string arg = args[nextarg]; if (arg.Equals("--ant")) { if (null != antennaList) { Console.WriteLine("Duplicate argument: --ant specified more than once"); Usage(); } antennaList = ParseAntennaList(args, nextarg); nextarg++; } else { Console.WriteLine("Argument {0}:\"{1}\" is not recognized", nextarg, arg); Usage(); } } try { // Create Reader object, connecting to physical device. // Wrap reader in a "using" block to get automatic // reader shutdown (using IDisposable interface). using (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(); } r.ParamSet("/reader/region/id", supportedRegions[0]); } if (r.isAntDetectEnabled(antennaList)) { Console.WriteLine("Module doesn't has antenna detection support please provide antenna list"); Usage(); } //Use first antenna for operation if (antennaList != null) { r.ParamSet("/reader/tagop/antenna", antennaList[0]); } if (enableFilter) { // If select filter is to be enabled byte[] mask = new byte[] { (byte)0x30, (byte)0x28, (byte)0x35, (byte)0x4D, (byte)0x82, (byte)0x02, (byte)0x02, (byte)0x80, (byte)0x00, (byte)0x01, (byte)0x04, (byte)0xAC }; filter = new Gen2.Select(false, Gen2.Bank.EPC, 32, 96, mask); } //Get Sensor Data of EM4325 tag bool sendUid = true; bool sendNewSample = true; Gen2.EMMicro.EM4325.GetSensorData getSensorOp = new Gen2.EMMicro.EM4325.GetSensorData(sendUid, sendNewSample); try { Console.WriteLine("****Executing standalone tag operation of Get sensor Data command of EM4325 tag****"); byte[] response = (byte[])r.ExecuteTagOp(getSensorOp, filter); // Parse the response of GetSensorData Console.WriteLine("****Get sensor Data command is success****"); GetSensorDataResponse rData = new GetSensorDataResponse(response); Console.WriteLine(rData.ToString()); } catch (Exception ex) { Console.WriteLine("Exception from executing get Sensor Data command: " + ex.Message); } //Embedded tag operation of Get sensor data try { Console.WriteLine("****Executing embedded tag operation of Get sensor Data command of EM4325 tag****"); embeddedRead(TagProtocol.GEN2, filter, getSensorOp); } catch (Exception ex) { Console.WriteLine("Exception from embedded get sensor data: " + ex.Message); } //Reset alarms command // Read back the temperature control word at 0xEC address to verify reset enable alarm bit is set before executing reset alarm tag op. Console.WriteLine("Reading Temperature control word 1 before resetting alarms to ensure reset enable bit is set to 1"); byte[] filterMask = new byte[] { (byte)0x04, (byte)0xc2 }; Gen2.Select select = new Gen2.Select(false, Gen2.Bank.EPC, 0x70, 16, filterMask); Gen2.ReadData rdata = new Gen2.ReadData(Gen2.Bank.USER, 0xEC, (byte)0x1); ushort[] resp = (ushort[])r.ExecuteTagOp(rdata, select); Console.WriteLine("Temp control word 1: "); foreach (ushort i in resp) { Console.Write(" {0:X4}", i); } Console.WriteLine("\n"); // If temperature control word is not 0x4000, write the data if (resp[0] != 0x4000) { ushort[] writeData = new ushort[] { 0x4000 }; Gen2.WriteData wData = new Gen2.WriteData(Gen2.Bank.USER, 0xEC, writeData); r.ExecuteTagOp(wData, select); } Gen2.EMMicro.EM4325.ResetAlarms resetAlarmsOp = new Gen2.EMMicro.EM4325.ResetAlarms(); try { Console.WriteLine("****Executing standalone tag operation of Reset alarms command of EM4325 tag****"); r.ExecuteTagOp(resetAlarmsOp, filter); Console.WriteLine("****Reset Alarms command is success****"); } catch (Exception ex) { Console.WriteLine("Exception from executing reset alarms : " + ex.Message); } //Embedded tag operation of reset alarms command try { Console.WriteLine("****Executing embedded tag operation of reset alarms command of EM4325 tag****"); embeddedRead(TagProtocol.GEN2, filter, resetAlarmsOp); } catch (Exception ex) { Console.WriteLine("Exception from embedded reset alarms command: " + ex.Message); } } } catch (ReaderException re) { Console.WriteLine("Error: " + re.Message); Console.Out.Flush(); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }