identity_item_data.cpp
Go to the documentation of this file.
1 
27 
28 namespace eip {
29 
31 {
32  // TODO: verify that this is correct
33  return sizeof(encap_protocol_version)
34  + sizeof(sockaddr)
35  + sizeof(vendor_id)
36  + sizeof(device_type)
37  + sizeof(product_code)
38  + sizeof(revision)
39  + sizeof(status)
40  + sizeof(serial_number)
41  + sizeof(EIP_USINT)
42  + product_name.length()
43  + sizeof(state);
44 }
45 
46 Writer& IdentityItemData::serialize(Writer& writer) const
47 {
48  writer.write(encap_protocol_version);
49  writer.write(sockaddr);
50  writer.write(vendor_id);
51  writer.write(device_type);
52  writer.write(product_code);
53  writer.write(revision);
54  writer.write(status);
55  writer.write(serial_number);
56 
57  EIP_USINT name_length = product_name.size();
58  writer.write(name_length);
59  writer.writeBytes(product_name.c_str(), name_length);
60  writer.write(state);
61  return writer;
62 }
63 
64 Reader& IdentityItemData::deserialize(Reader& reader)
65 {
66  reader.read(encap_protocol_version);
67  reader.read(sockaddr);
68  reader.read(vendor_id);
69  reader.read(device_type);
70  reader.read(product_code);
71  reader.read(revision);
72  reader.read(status);
73  reader.read(serial_number);
74 
75  EIP_USINT name_length;
76  reader.read(name_length);
77  product_name.resize(name_length);
78  reader.readBytes(&product_name[0], name_length);
79  reader.read(state);
80  return reader;
81 }
82 
83 } // namespace eip
uint8_t EIP_USINT
Definition: eip_types.h:36
virtual size_t getLength() const
Definition: connection.h:41
virtual Writer & serialize(Writer &writer) const
virtual Reader & deserialize(Reader &reader, size_t length)


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