message_router_response.cpp
Go to the documentation of this file.
1 
26 #include <boost/make_shared.hpp>
27 
30 
31 using boost::make_shared;
32 
33 namespace eip {
34 
35 using serialization::SerializableBuffer;
36 
38 {
39  size_t result = sizeof(service) + sizeof(EIP_USINT) + sizeof(general_status)
40  + sizeof(EIP_USINT);
42  {
43  result += additional_status_->getLength();
44  }
45  if (response_data_)
46  {
47  result += response_data_->getLength();
48  }
49  return result;
50 }
51 
52 Reader& MessageRouterResponse::deserialize(Reader& reader, size_t length)
53 {
54  reader.read(service);
55  // read the general status twice to skip the reserved data
56  reader.read(general_status);
57  reader.read(general_status);
58  EIP_USINT additional_status_length;
59  reader.read(additional_status_length);
60  additional_status_ = readData(reader, (size_t)2*additional_status_length);
61  response_data_ = readData(reader, length - reader.getByteCount());
62  return reader;
63 }
64 
65 shared_ptr<Serializable> MessageRouterResponse::readData(Reader& reader, int length)
66 {
67  shared_ptr<SerializableBuffer> sb;
68  if (length > 0)
69  {
70  sb = make_shared<SerializableBuffer>();
71  sb->deserialize(reader, length);
72  }
73  return sb;
74 }
75 
76 } // namespace eip
uint8_t EIP_USINT
Definition: eip_types.h:36
shared_ptr< Serializable > readData(Reader &reader, int length)
Definition: connection.h:41
virtual Reader & deserialize(Reader &reader, size_t length)
shared_ptr< Serializable > response_data_
shared_ptr< Serializable > additional_status_
virtual size_t getLength() const


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Mon Jun 10 2019 14:00:16