public DCP.BlockErrors SendSetRequest(PhysicalAddress destination, int timeoutMs, int retries, DCP.BlockOptions option, DCP.BlockQualifiers qualifiers, byte[] data) { for (int r = 0; r < retries; r++) { IAsyncResult asyncResult = BeginSetRequest(destination, option, qualifiers, data); try { return(EndSetRequest(asyncResult, timeoutMs)); } catch (TimeoutException) { //continue } } throw new TimeoutException("No response received"); }
public IAsyncResult BeginSetRequest(PhysicalAddress destination, DCP.BlockOptions option, DCP.BlockQualifiers qualifiers, byte[] data) { Trace.WriteLine("Sending Set " + option.ToString() + " request", null); MemoryStream mem = new MemoryStream(); //ethernet Ethernet.Encode(mem, destination, adapter.MacAddress, Ethernet.Type.VLanTaggedFrame); //VLAN VLAN.Encode(mem, VLAN.Priorities.Priority0, VLAN.Type.PN); //Profinet Real Time RT.EncodeFrameId(mem, RT.FrameIds.DCP_Get_Set_PDU); //Profinet DCP UInt16 xid = ++lastXid; DCP.EncodeSetRequest(mem, xid, option, qualifiers, data); //start Async return(new ProfinetAsyncDcpResult(this, mem, xid)); }