public static EncapsReply SendMR_Request(Eip.SessionInfo session, MessageRouterRequest request) { CommonPacketItem dataItem = CommonPacketItem.GetUnconnectedDataItem(request.Pack()); EncapsReply response = session.SendRRData(CommonPacketItem.GetNullAddressItem(), dataItem); return(response); }
private void UpdateState() { EncapsRRData rrData = new EncapsRRData(); rrData.CPF = new CommonPacket(); rrData.CPF.AddressItem = CommonPacketItem.GetNullAddressItem(); UnconnectedSend ucmm = new UnconnectedSend(); ucmm.RequestPath = CommonPaths.ConnectionManager; ucmm.RoutePath = _path; ucmm.Priority_TimeTick = _session.ConnectionParameters.PriorityAndTick; ucmm.Timeout_Ticks = _session.ConnectionParameters.ConnectionTimeoutTicks; ucmm.MessageRequest = new MR_Request(); ucmm.MessageRequest.Service = 0x03; ucmm.MessageRequest.Request_Path = CommonPaths.IdentityObject; ucmm.MessageRequest.Request_Data = new byte[] { 0x07, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00 }; rrData.CPF.DataItem = CommonPacketItem.GetUnconnectedDataItem(ucmm.Pack()); EncapsReply reply = _session.SendRRData(rrData.CPF.AddressItem, rrData.CPF.DataItem); if (reply == null) { return; } if (reply.Status == 0) { UnconnectedSendReply ucReply = reply; if (ucReply.GeneralStatus == 0x00) { UnconnectedSendReply_Success succReply = ucReply as UnconnectedSendReply_Success; DecodeAttributeReply(succReply.ServiceResponse); } else { //Failed, for some reason... //TODO: Decipher the code and add it to the error property } } }
private List <LogixTagInfo> GetTagInfo() { CommonPacketItem addressItem = CommonPacketItem.GetNullAddressItem(); UnconnectedSend ucmm = new UnconnectedSend(); ucmm.RequestPath = CommonPaths.ConnectionManager; ucmm.RoutePath = _path; ucmm.Priority_TimeTick = _session.ConnectionParameters.PriorityAndTick; ucmm.Timeout_Ticks = _session.ConnectionParameters.ConnectionTimeoutTicks; ucmm.MessageRequest = new MR_Request(); ucmm.MessageRequest.Service = 0x55; ucmm.MessageRequest.Request_Path = new byte[] { 0x20, 0x6B, 0x25, 0x00, 0x00, 0x00 }; //Last 2 bytes are the offset... ucmm.MessageRequest.Request_Data = new byte[] { 0x04, 0x00, 0x02, 0x00, 0x07, 0x00, 0x08, 0x00, 0x01, 0x00 }; CommonPacketItem dataItem = CommonPacketItem.GetUnconnectedDataItem(ucmm.Pack()); EncapsReply reply = _session.SendRRData(addressItem, dataItem); List <LogixTagInfo> retVal = new List <LogixTagInfo>(); if (reply.Status == 0) { UnconnectedSendReply ucReply = reply; if (ucReply.GeneralStatus == 0x00 || ucReply.GeneralStatus == 0x06) { UnconnectedSendReply_Success succReply = ucReply as UnconnectedSendReply_Success; List <byte> replyBytes = new List <byte>(); uint lastOffset = 0x0000; retVal.AddRange(DecodeTagInfo(succReply.ServiceResponse, out lastOffset)); while (ucReply.GeneralStatus == 0x06) { lastOffset += 1; if (lastOffset <= 0xFFFF) { Buffer.BlockCopy(BitConverter.GetBytes((ushort)lastOffset), 0, ucmm.MessageRequest.Request_Path, 4, 2); } else { byte[] tempPath = new byte[8]; Buffer.BlockCopy(ucmm.MessageRequest.Request_Path, 0, tempPath, 0, 6); Buffer.BlockCopy(BitConverter.GetBytes(lastOffset), 0, tempPath, 4, 4); ucmm.MessageRequest.Request_Path = tempPath; } dataItem = CommonPacketItem.GetUnconnectedDataItem(ucmm.Pack()); reply = _session.SendRRData(addressItem, dataItem); if (reply.Status == 0x00) { ucReply = reply; if (ucReply.GeneralStatus == 0x00 || ucReply.GeneralStatus == 0x06) { succReply = ucReply as UnconnectedSendReply_Success; retVal.AddRange(DecodeTagInfo(succReply.ServiceResponse, out lastOffset)); } } } } } return(retVal); }