rr_data.cpp
Go to the documentation of this file.
1 
26 #include <boost/shared_ptr.hpp>
27 #include <boost/make_shared.hpp>
28 #include <console_bridge/console.h>
29 
33 
34 using boost::shared_ptr;
35 using boost::make_shared;
36 
37 namespace eip {
38 
40 {
41  writer.write(interface_handle);
42  writer.write(timeout);
43  CPFPacket pkt;
44  pkt.getItems().push_back(CPFItem());
46  pkt.serialize(writer);
47  return writer;
48 }
49 
51 {
52  reader.read(interface_handle);
53  reader.read(timeout);
54  CPFPacket pkt;
55  pkt.deserialize(reader);
56 
57  // check that CPF items are correct
58  if (pkt.getItemCount() < 2)
59  {
60  throw std::logic_error("Not enough items in RR Data");
61  }
62  if (pkt.getItemCount() > 2)
63  {
64  CONSOLE_BRIDGE_logWarn("More than 2 items in RR data response");
65  }
66  if (pkt.getItems().at(0).getItemType() != EIP_ITEM_NULL)
67  {
68  throw std::logic_error("Address other than null in RR Data");
69  }
70  if (pkt.getItems().at(0).getDataLength() != 0)
71  {
72  throw std::logic_error("Data length greater than zero in null address type");
73  }
74 
75  if (pkt.getItems().at(1).getItemType() != EIP_ITEM_UNCONNECTED_MESSAGE)
76  {
77  throw std::logic_error("Unexpected data type in RR Data");
78  }
79 
80  setData(pkt.getItems().at(1));
81  return reader;
82 }
83 
84 } // namespace eip
eip::CPFPacket
Definition: cpf_packet.h:49
eip::serialization::Writer
Definition: writer.h:41
eip::serialization::Reader
Definition: reader.h:42
eip
Definition: connection.h:41
eip::CPFPacket::serialize
virtual Writer & serialize(Writer &writer) const
Definition: cpf_packet.cpp:46
eip::CPFPacket::getItems
vector< CPFItem > & getItems()
Definition: cpf_packet.h:66
eip::RRData::interface_handle
EIP_UDINT interface_handle
Definition: rr_data.h:55
eip::serialization::Writer::write
void write(const T &v)
Definition: writer.h:50
eip::serialization::Reader::read
void read(T &v)
Definition: reader.h:51
eip::RRData::deserialize
virtual Reader & deserialize(Reader &reader, size_t length)
Definition: rr_data.h:88
EIP_ITEM_NULL
@ EIP_ITEM_NULL
Definition: eip_types.h:86
eip::RRData::serialize
virtual Writer & serialize(Writer &writer) const
Definition: rr_data.cpp:39
rr_data.h
cpf_item.h
eip::RRData::setData
virtual void setData(CPFItem &item)
Definition: rr_data.h:116
eip::RRData::getData
virtual shared_ptr< Serializable > getData() const
Definition: rr_data.h:107
eip::CPFPacket::getItemCount
EIP_UINT getItemCount() const
Definition: cpf_packet.h:57
eip::RRData::timeout
EIP_UINT timeout
Definition: rr_data.h:56
cpf_packet.h
eip::CPFItem
Definition: cpf_item.h:48
eip::CPFPacket::deserialize
virtual Reader & deserialize(Reader &reader, size_t length)
Definition: cpf_packet.h:89
EIP_ITEM_UNCONNECTED_MESSAGE
@ EIP_ITEM_UNCONNECTED_MESSAGE
Definition: eip_types.h:90


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Wed Mar 2 2022 00:38:56