ParseFirmwareVersion.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::FirmwareVersion& firmware_version) 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  firmware_version.setFirmwareVersion(readFirmwareVersion(data_ptr));
52  return true;
53 }
54 
55 
56 std::string
57 ParseFirmwareVersion::readFirmwareVersion(std::vector<uint8_t>::const_iterator data_ptr) const
58 {
59  uint16_t string_length = read_write_helper::readUint16LittleEndian(data_ptr + 0);
60 
61  std::string result;
62  for (uint16_t i = 0; i < string_length; i++)
63  {
64  result.push_back(read_write_helper::readUint16LittleEndian(data_ptr + 2 + i));
65  }
66  return result;
67 }
68 
69 
70 } // namespace data_processing
71 } // 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::FirmwareVersion &firmware_version) const
Parses a tcp sequence to read the firmware version of the sensor.
std::string readFirmwareVersion(std::vector< uint8_t >::const_iterator data_ptr) const
Class containing the firmware version of a laser scanner.
void setFirmwareVersion(const std::string &firmware_version)
Sets the firmware version for the scanner.
uint16_t readUint16LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 16-bit integer at offset in little endian encoding.


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