ParseDeviceName.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 
00024 // -- END LICENSE BLOCK ------------------------------------------------
00025 
00026 //----------------------------------------------------------------------
00033 //----------------------------------------------------------------------
00034 
00035 #include <sick_safetyscanners/data_processing/ParseDeviceName.h>
00036 
00037 #include <sick_safetyscanners/cola2/Command.h>
00038 
00039 namespace sick {
00040 namespace data_processing {
00041 
00042 ParseDeviceName::ParseDeviceName()
00043 {
00044   m_reader_ptr = std::make_shared<sick::data_processing::ReadWriteHelper>();
00045 }
00046 
00047 
00048 bool ParseDeviceName::parseTCPSequence(const datastructure::PacketBuffer& buffer,
00049                                        std::string& device_name) const
00050 {
00051   const uint8_t* data_ptr(buffer.getBuffer().data());
00052   device_name = readDeviceName(data_ptr);
00053   return true;
00054 }
00055 
00056 
00057 std::string ParseDeviceName::readDeviceName(const uint8_t*& data_ptr) const
00058 {
00059   uint16_t string_length = m_reader_ptr->readuint16_tLittleEndian(data_ptr, 0);
00060 
00061   std::string name;
00062   for (uint16_t i = 0; i < string_length; i++)
00063   {
00064     name.push_back(m_reader_ptr->readuint16_tLittleEndian(data_ptr, 2 + i));
00065   }
00066   return name;
00067 }
00068 
00069 
00070 } // namespace data_processing
00071 } // namespace sick


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Tue May 7 2019 03:27:36