ParseApplicationNameData.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 
24 // -- END LICENSE BLOCK ------------------------------------------------
25 
26 //----------------------------------------------------------------------
33 //----------------------------------------------------------------------
34 
36 
38 
39 namespace sick {
40 namespace data_processing {
41 
43 
44 
46  const datastructure::PacketBuffer& buffer,
47  sick::datastructure::ApplicationName& application_name) const
48 {
49  // Keep our own copy of the shared_ptr to keep the iterators valid
50  const std::shared_ptr<std::vector<uint8_t> const> vec_ptr = buffer.getBuffer();
51  std::vector<uint8_t>::const_iterator data_ptr = vec_ptr->begin();
52  application_name.setVersionCVersion(readVersionIndicator(data_ptr));
53  application_name.setVersionMajorVersionNumber(readMajorNumber(data_ptr));
54  application_name.setVersionMinorVersionNumber(readMinorNumber(data_ptr));
55  application_name.setVersionReleaseNumber(readReleaseNumber(data_ptr));
56  application_name.setNameLength(readNameLength(data_ptr));
57  application_name.setApplicationName(readApplicationName(data_ptr));
58  return true;
59 }
60 
61 std::string
62 ParseApplicationNameData::readVersionIndicator(std::vector<uint8_t>::const_iterator data_ptr) const
63 {
64  std::string result;
65  result.push_back(read_write_helper::readUint8(data_ptr + 0));
66  return result;
67 }
68 
69 uint8_t
70 ParseApplicationNameData::readMajorNumber(std::vector<uint8_t>::const_iterator data_ptr) const
71 {
72  return read_write_helper::readUint8(data_ptr + 1);
73 }
74 
75 uint8_t
76 ParseApplicationNameData::readMinorNumber(std::vector<uint8_t>::const_iterator data_ptr) const
77 {
78  return read_write_helper::readUint8(data_ptr + 2);
79 }
80 
81 uint8_t
82 ParseApplicationNameData::readReleaseNumber(std::vector<uint8_t>::const_iterator data_ptr) const
83 {
84  return read_write_helper::readUint8(data_ptr + 3);
85 }
86 
87 uint32_t
88 ParseApplicationNameData::readNameLength(std::vector<uint8_t>::const_iterator data_ptr) const
89 {
90  return read_write_helper::readUint32LittleEndian(data_ptr + 4);
91 }
92 
93 
94 std::string
95 ParseApplicationNameData::readApplicationName(std::vector<uint8_t>::const_iterator data_ptr) const
96 {
97  uint32_t name_length = read_write_helper::readUint32LittleEndian(data_ptr + 4);
98  std::string name;
99  for (uint8_t i = 0; i < name_length; i++)
100  {
101  name.push_back(read_write_helper::readUint8(data_ptr + 8 + i));
102  }
103  return name;
104 }
105 
106 
107 } // namespace data_processing
108 } // namespace sick
A packetbuffer for the raw data from the sensor.
Definition: PacketBuffer.h:61
std::shared_ptr< std::vector< uint8_t > const > getBuffer() const
Getter to return a copy of the data saved in the PacketBuffer.
bool parseTCPSequence(const datastructure::PacketBuffer &buffer, datastructure::ApplicationName &application_name) const
Parses a tcp sequence to read the type code of the sensor.
void setNameLength(const uint32_t &name_length)
Sets the length of the application name.
uint32_t readUint32LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 32-bit integer at offset in little endian encoding.
uint8_t readReleaseNumber(std::vector< uint8_t >::const_iterator data_ptr) const
std::string readVersionIndicator(std::vector< uint8_t >::const_iterator data_ptr) const
void setVersionReleaseNumber(const uint8_t &version_release_number)
Sets the version release number for the scanner.
std::string readApplicationName(std::vector< uint8_t >::const_iterator data_ptr) const
void setVersionMinorVersionNumber(const uint8_t &version_minor_version_number)
Sets the minor version number for the scanner.
uint32_t readNameLength(std::vector< uint8_t >::const_iterator data_ptr) const
void setVersionMajorVersionNumber(const uint8_t &version_major_version_number)
Sets the major version number for the scanner.
uint8_t readMajorNumber(std::vector< uint8_t >::const_iterator data_ptr) const
uint8_t readUint8(std::vector< uint8_t >::const_iterator it)
Read an unsigned 8-bit integer at offset.
void setApplicationName(const std::string &application_name)
Sets the application name for the scanner.
uint8_t readMinorNumber(std::vector< uint8_t >::const_iterator data_ptr) const
Class containing the application name of a laser scanner.
void setVersionCVersion(const std::string &version_c_version)
Sets the version indicator for the scanner.


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Fri Apr 2 2021 02:45:41