public override bool SelectTag(ref Tag tag) { STPv3Request request = new STPv3Request(); request.Tag = tag; request.RID = this.m_RID; request.Command = STPv3Commands.SELECT_TAG; issue: request.Issue(this.m_device); STPv3Response response = request.GetResponse(); if (response == null) { return(false); } if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF) { goto issue; } if (!response.Success) { return(false); } tag.TID = response.TID; if (tag.Type == 0x0000) { tag.Type = response.TagType; } return(true); }
/// <summary> /// Uploads new firmware to a reader. Takes a string containing the path to the .shf file /// </summary> /// <param name="file">Path to .shf file. String.</param> /// <returns></returns> public bool UploadFirmware(string file) { STPv3Request request = new STPv3Request(); request.RID = this.m_RID; request.Command = STPv3Commands.ENTER_BOOTLOAD; issue: request.Issue(this.m_device); STPv3Response response = request.GetResponse(); if (response == null) { return(false); } if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF) { goto issue; } if (!response.Success) { return(false); } STPv3Request.UploadFirmware(this.m_device, file); return(true); }
/// <summary> /// Reads a stored default parameter from the reader. Address denotes parameter /// </summary> /// <param name="address">Address to read from</param> /// <param name="blocks">Number of blocks to write</param> /// <returns>Return null if read failed, data otherwise</returns> public byte[] RetrieveDefaultParameter(ushort address, ushort blocks) { STPv3Request request = new STPv3Request(); request.Command = STPv3Commands.RETRIEVE_DEFAULT_SYSTEM_PARAMETER; request.Address = address; request.Blocks = blocks; request.RID = this.m_RID; issue: request.Issue(this.m_device); STPv3Response response = request.GetResponse(); if (response == null) { return(null); } if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF) { goto issue; } if (!response.Success) { return(null); } return(response.Data); }
/// <summary> /// Writes a new default system parameter. Address denotes parameter /// </summary> /// <param name="data">Data to write</param> /// <param name="address">Address to write to</param> /// <param name="blocks">Number of blocks to write</param> public bool StoreDefaultParameter(byte[] data, ushort address, ushort blocks) { STPv3Request request = new STPv3Request(); request.Command = STPv3Commands.STORE_DEFAULT_SYSTEM_PARAMETER; request.Address = address; request.Blocks = blocks; request.Data = data; request.RID = this.m_RID; issue: request.Issue(this.m_device); STPv3Response response = request.GetResponse(); if (response == null) { return(false); } if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF) { goto issue; } if (!response.Success) { return(false); } return(true); }
public override bool WriteTagData(Tag tag, byte[] data, ushort address, ushort blocks) { STPv3Request request = new STPv3Request(); request.Tag = tag; request.Command = STPv3Commands.WRITE_TAG; request.Data = data; request.Address = address; request.Blocks = blocks; request.RID = this.m_RID; issue: request.Issue(this.m_device); STPv3Response response = request.GetResponse(); if (response == null) { return(false); } if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF) { goto issue; } if (!response.Success) { return(false); } return(true); }
public override byte[] ReadTagData(Tag tag, ushort address, ushort blocks) { STPv3Request request = new STPv3Request(); request.Tag = tag; request.Command = STPv3Commands.READ_TAG; request.Address = address; request.Blocks = blocks; request.RID = this.m_RID; issue: request.Issue(this.m_device); STPv3Response response = request.GetResponse(); if (response == null) { return(null); } if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF) { goto issue; } if (!response.Success) { return(null); } return(response.Data); }
private string formatCard(STPv3Response rfidResponse, string antennaId) { return(String.Format("{0}.{1}", String.Join("", Array.ConvertAll <byte, string>(rfidResponse.TID, delegate(byte value) { return String.Format("{0:X2}", value); })), antennaId)); }
/// <summary> /// Writes a system parameter to the reader. Address denotes parameter /// </summary> /// <param name="data">Data to be written</param> /// <param name="address">Address to write to</param> /// <param name="blocks">Number of blocks to write</param> public bool WriteSystemParameter(byte[] data, ushort address, ushort blocks) { STPv3Request request = new STPv3Request(); request.Command = STPv3Commands.WRITE_SYSTEM_PARAMETER; request.Address = address; request.Blocks = blocks; request.Data = data; request.RID = this.m_RID; issue: request.Issue(this.m_device); STPv3Response response = request.GetResponse(); if (response == null) { return(false); } if (response.ResponseCode == STPv3ResponseCode.SELECT_TAG_LOOP_OFF) { goto issue; } if (!response.Success) { return(false); } if (address == 4) // Reader ID is being set { request.Data.CopyTo(this.m_RID, 0); } return(true); }
/** * Asks for data * * NOTE : currently all this meathod is used for is finding the serial number * @param cmmd - the command to be issues * @param adress - the address of the memory * @param block - the blocks of the memory * @param device - the device to be read * */ private void sendReadRequest(STPv3Command cmmd, ushort adress, ushort block, USBDevice device) { //new request STPv3Request request = new STPv3Request(); try { //set param of the request request.Command = cmmd; request.Address = adress; request.Blocks = block; //issue request request.Issue(device); //get response STPv3Response response = request.GetResponse(); //if it fails report and exit if ((response == null) || (!response.Success)) { Console.Out.WriteLine("Unable to read serial number from reader"); Console.In.Read(); return; } //else print out the data Console.Out.WriteLine(String.Format("Serial Number:{0}", String.Join("", Array.ConvertAll <byte, string> (response.Data, delegate(byte value) { return(String.Format("{0:X2}", value)); })))); } catch (Exception ex) { Console.Out.WriteLine(ex.StackTrace); } }
static void Main(string[] args) { STPv3Reader reader = null; string s; MFDevice myDevice = null; MFDevice[] ar = MFDeviceFactory.Enumerate(); if (ar.Length != 0) { foreach (MFDevice mfd in ar) { s = ""; Debug.Print(""); Debug.Print("Begin Report"); Debug.Print("************************"); Debug.Print("IP Address:" + mfd.MFIPEndPoint); s = BitConverter.ToString(mfd.MacAddr).Replace("-", ""); Debug.Print("MAC ADDRESS:" + s); Debug.Print("ADDRESS FAMILY:" + mfd.AddrFamily); Debug.Print("REMOTE SOCKET PORT:" + mfd.RemotePort.ToString()); if (s == "00409D3D4897") //<--your Device Mac Address here { myDevice = mfd; break; } } try { //System parameter reads if (myDevice == null) { //My Device is not on the Network Debug.Print("NULL OBJECT ERROR"); return; } myDevice.SetReadTimeOut = 500; reader = new STPv3Reader(myDevice); reader.Open(); Debug.Print("Hardware Version:" + reader.HardwareVersion); Debug.Print("Product Code:" + reader.ProductCode); Debug.Print("Reader Firmware:" + reader.FirmwareVersion); Debug.Print(String.Format("Reader ID: {0}", String.Join("", Array.ConvertAll <byte, string>(reader.ReaderID, delegate(byte value) { return(String.Format("{0:X2}", value)); })))); Debug.Print("Reader Start Frequency:" + reader.StartFrequency); Debug.Print("Reader Stop Frequency: " + reader.StopFrequency); Debug.Print("Reader Power Level:" + reader.PowerLevel); Debug.Print("INVENTORY EXAMPLE"); byte[] r = new byte[1]; r[0] = 20; //20 retries, anticipate 10 tags in the field STPv3Response response = null; STPv3Request requestTag = new STPv3Request(); requestTag.Command = STPv3Commands.WRITE_SYSTEM_PARAMETER; // set reader retries, usually the number of retries should be twice as much as //the anticipated tags in the field! requestTag.Address = 0x0011; requestTag.Blocks = 0x01; requestTag.Data = r; requestTag.Issue(myDevice); response = requestTag.GetResponse(); if (!response.Success) { Debug.Print("Cannot set retries"); } STPv3Response stpresponse = null; STPv3Request request = new STPv3Request(); request.Command = STPv3Commands.SELECT_TAG; request.Inventory = true; Tag tag = new Tag(); tag.Type = TagType.AUTO_DETECT; request.Tag = tag; //change the time out for Inventory and Loop modes myDevice.SetReadTimeOut = 20; try { request.Issue(myDevice); while (true) { stpresponse = request.GetResponse(); if (stpresponse == null) { Debug.Print("NULL RESPONSE"); } if (stpresponse.ResponseCode == STPv3ResponseCode.SELECT_TAG_PASS) { Debug.Print(String.Format("Tag found: {0} -> {1}", Enum.GetName(typeof(SkyeTek.Tags.TagType), stpresponse.TagType), String.Join("", Array.ConvertAll <byte, string>(stpresponse.TID, delegate(byte value) { return(String.Format("{0:X2}", value)); })))); } if (stpresponse.ResponseCode == STPv3ResponseCode.SELECT_TAG_INVENTORY_DONE) { Debug.Print("RECEIVED SELECT_TAG_INVENTORY_DONE"); break; } //Readers return select tag fail as inventory end, if no tags in field if (stpresponse.ResponseCode == STPv3ResponseCode.SELECT_TAG_FAIL) { Debug.Print("RECEIVED SELECT_TAG_FAIL"); break; } } } catch (Exception ee) { Debug.Print("Exception " + ee.Message); } Debug.Print(""); Debug.Print("*************** End Report ************************"); reader.Close(); } catch (SocketException ex) { Debug.Print(ex.ToString()); } catch (Exception e) { Debug.Print("Exception " + e.ToString()); reader.Close(); } } }
private void appendResponse(STPv3Response response) { this.responsesBox.Items.Add(response); }
private void appendResponse(STPv3Response response) { this.responsesBox.Items.Add(response); }