ParseUserNameData.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  sick::datastructure::UserName& user_name) const
47 {
48  // Keep our own copy of the shared_ptr to keep the iterators valid
49  const std::shared_ptr<std::vector<uint8_t> const> vec_ptr = buffer.getBuffer();
50  std::vector<uint8_t>::const_iterator data_ptr = vec_ptr->begin();
51  user_name.setVersionCVersion(readVersionIndicator(data_ptr));
52  user_name.setVersionMajorVersionNumber(readMajorNumber(data_ptr));
53  user_name.setVersionMinorVersionNumber(readMinorNumber(data_ptr));
54  user_name.setVersionReleaseNumber(readReleaseNumber(data_ptr));
55  user_name.setNameLength(readNameLength(data_ptr));
56  user_name.setUserName(readUserName(data_ptr));
57  return true;
58 }
59 
60 std::string
61 ParseUserNameData::readVersionIndicator(std::vector<uint8_t>::const_iterator data_ptr) const
62 {
63  std::string result;
64  result.push_back(read_write_helper::readUint8(data_ptr + 0));
65  return result;
66 }
67 
68 uint8_t ParseUserNameData::readMajorNumber(std::vector<uint8_t>::const_iterator data_ptr) const
69 {
70  return read_write_helper::readUint8(data_ptr + 1);
71 }
72 
73 uint8_t ParseUserNameData::readMinorNumber(std::vector<uint8_t>::const_iterator data_ptr) const
74 {
75  return read_write_helper::readUint8(data_ptr + 2);
76 }
77 
78 uint8_t ParseUserNameData::readReleaseNumber(std::vector<uint8_t>::const_iterator data_ptr) const
79 {
80  return read_write_helper::readUint8(data_ptr + 3);
81 }
82 
83 uint32_t ParseUserNameData::readNameLength(std::vector<uint8_t>::const_iterator data_ptr) const
84 {
85  return read_write_helper::readUint32LittleEndian(data_ptr + 4);
86 }
87 
88 
89 std::string ParseUserNameData::readUserName(std::vector<uint8_t>::const_iterator data_ptr) const
90 {
91  uint32_t name_length = read_write_helper::readUint32LittleEndian(data_ptr + 4);
92  std::string name;
93  for (uint8_t i = 0; i < name_length; i++)
94  {
95  name.push_back(read_write_helper::readUint8(data_ptr + 8 + i));
96  }
97  return name;
98 }
99 
100 
101 } // namespace data_processing
102 } // namespace sick
void setNameLength(const uint32_t &name_length)
Sets the length of the user name.
Definition: UserName.cpp:87
std::string readUserName(std::vector< uint8_t >::const_iterator data_ptr) const
Class containing the user name of a laser scanner.
Definition: UserName.h:47
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::UserName &user_name) const
Parses a tcp sequence to read the type code of the sensor.
void setVersionCVersion(const std::string &version_c_version)
Sets the version indicator for the scanner.
Definition: UserName.cpp:47
uint32_t readUint32LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 32-bit integer at offset in little endian encoding.
uint8_t readMinorNumber(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.
Definition: UserName.cpp:77
void setUserName(const std::string &user_name)
Sets the user name for the scanner.
Definition: UserName.cpp:97
ParseUserNameData()
Constructor of the parser.
void setVersionMinorVersionNumber(const uint8_t &version_minor_version_number)
Sets the minor version number for the scanner.
Definition: UserName.cpp:67
std::string readVersionIndicator(std::vector< uint8_t >::const_iterator data_ptr) const
uint8_t readMajorNumber(std::vector< uint8_t >::const_iterator data_ptr) const
uint32_t readNameLength(std::vector< uint8_t >::const_iterator data_ptr) const
uint8_t readReleaseNumber(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.
Definition: UserName.cpp:57
uint8_t readUint8(std::vector< uint8_t >::const_iterator it)
Read an unsigned 8-bit integer at offset.


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