ParseProjectName.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  datastructure::ProjectName& project_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  project_name.setProjectName(readProjectName(data_ptr));
52  return true;
53 }
54 
55 
56 std::string ParseProjectName::readProjectName(std::vector<uint8_t>::const_iterator data_ptr) const
57 {
58  uint16_t string_length = read_write_helper::readUint16LittleEndian(data_ptr + 0);
59 
60  std::string name;
61  for (uint16_t i = 0; i < string_length; i++)
62  {
63  name.push_back(read_write_helper::readUint8LittleEndian(data_ptr + 2 + i));
64  }
65  return name;
66 }
67 
68 
69 } // namespace data_processing
70 } // 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.
uint8_t readUint8LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 8-bit integer at offset in big little encoding.
bool parseTCPSequence(const datastructure::PacketBuffer &buffer, datastructure::ProjectName &project_name) const
Parses a tcp sequence to read the project name of the sensor.
void setProjectName(const std::string &project_name)
Sets the project name for the scanner.
Definition: ProjectName.cpp:47
std::string readProjectName(std::vector< uint8_t >::const_iterator data_ptr) const
Class containing the project name of a laser scanner.
Definition: ProjectName.h:47
uint16_t readUint16LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 16-bit integer at offset in little endian encoding.
ParseProjectName()
Constructor of the parser.


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