/// <summary> /// Sends an array of `data` to a tag (with EPC starting with `tagId`) to a specific `address`. /// /// The transfer is done by grouping multiple BlockWrite commands into a single AccessSpec /// /// Note: with the current configuration `ReaderManager.SendData` tends to peform better /// </summary> public async Task <OperationResponse> SendDataBatch(ushort tagId, byte[] data, int bytesPerChunk, ushort baseAddress, TimeSpan?timeout = null) { this.PrepareReader(); var targetTag = LLRPHelpers.WispTag(tagId); var controlResponse = await this.SendControlWithPowerCheck(tagId, TagState.SetOffset, 0x0000); if (controlResponse.status != SecuCode.StatusCode.Success) { return(controlResponse); } var commands = new List <PARAM_C1G2BlockWrite>(); var offset = baseAddress; foreach (var chunk in data.Split(bytesPerChunk)) { var bytes = chunk.ToArray(); commands.Add(this.BlockWriteCmd(offset, bytes)); offset += (ushort)(bytes.Length / 2); } this.reader.Add_ContinuousAccessSpec(targetTag, commands.Select(a => a as IParameter).ToList()); return(await this.StartAndWaitBlockWriteAcks(commands, tagId, timeout)); }
/// <summary> /// Adds a new access spec for reading a number of bytes from the tag /// </summary> private void AddReadAccessSpec(ushort tagId, ushort memoryBank, ushort address, ushort length) { var accessSpecOp = LLRPHelpers.ReadMessage(memoryBank, address, length); var targetTag = LLRPHelpers.WispTag(tagId); this.reader.Add_ContinuousAccessSpec(targetTag, new List <IParameter> { accessSpecOp }); }
/// <summary> /// Adds a new access spec for sending a control message /// </summary> private PARAM_C1G2BlockWrite AddControlAccessSpec(ushort?tagId, ushort state, ushort value) { var accessSpecOp = LLRPHelpers.ControlMessage(state, value); var targetTag = LLRPHelpers.WispTag(tagId); this.reader.Add_ContinuousAccessSpec(targetTag, new List <IParameter> { accessSpecOp }); return(accessSpecOp); }
private Task <OperationResponse> SendDataBlock(ushort tagId, ushort offset, byte[] dataBlock, TimeSpan?timeout = null) { var targetTag = LLRPHelpers.WispTag(tagId); var accessSpec = this.BlockWriteCmd(offset, dataBlock); this.reader.Add_ContinuousAccessSpec(targetTag, new List <IParameter> { accessSpec }); return(this.StartAndWaitBlockWriteAcks(new List <PARAM_C1G2BlockWrite> { accessSpec }, tagId, timeout)); }