ParseSerialNumber.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::SerialNumber& serial_number) 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  serial_number.setSerialNumber(readSerialNumber(data_ptr));
52  return true;
53 }
54 
55 
56 std::string ParseSerialNumber::readSerialNumber(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 number;
61  for (uint16_t i = 0; i < string_length; i++)
62  {
63  number.push_back(read_write_helper::readUint16LittleEndian(data_ptr + 2 + i));
64  }
65  return number;
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.
std::string readSerialNumber(std::vector< uint8_t >::const_iterator data_ptr) const
ParseSerialNumber()
Constructor of the parser.
bool parseTCPSequence(const datastructure::PacketBuffer &buffer, datastructure::SerialNumber &serial_number) const
Parses a tcp sequence to read the serial number of the sensor.
Class containing the serial number of a laser scanner.
Definition: SerialNumber.h:47
uint16_t readUint16LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 16-bit integer at offset in little endian encoding.
void setSerialNumber(const std::string &serial_number)
Sets the serial number for the scanner.


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