driver/src/sick_scan_common.cpp
std::string stripControl(std::vector<unsigned char> s, int max_strlen = -1)
  {
    bool isParamBinary = false;
    int spaceCnt = 0x00;
    int cnt0x02 = 0;

    for (size_t i = 0; i < s.size(); i++)
    {
      if (s[i] != 0x02)
      {
        isParamBinary = false;

      }
      else
      {
        cnt0x02++;
      }
      if (i > 4)
      {
        break;
      }
    }
    if (4 == cnt0x02)
    {
      isParamBinary = true;
    }
    std::string dest;
    if (isParamBinary == true)
    {
      int parseState = 0;

      unsigned long lenId = 0x00;
      char szDummy[255] = {0};
      for (size_t i = 0; i < s.size(); i++)
      {
        switch (parseState)
        {
          case 0:
            if (s[i] == 0x02)
            {
              dest += "<STX>";
            }
            else
            {
              dest += "?????";
            }
            if (i == 3)
            {
              parseState = 1;
            }
            break;
          case 1:
            lenId |= s[i] << (8 * (7 - i));
            if (i == 7)
            {
              sprintf(szDummy, "<Len=%04lu>", lenId);
              dest += szDummy;
              parseState = 2;
            }
            break;
          case 2:
          {
            unsigned long dataProcessed = i - 8;
            if (s[i] == ' ')
            {
              spaceCnt++;
            }
            if (spaceCnt == 2)
            {
              parseState = 3;
            }
            dest += s[i];
            if (dataProcessed >= (lenId - 1))
            {
              parseState = 4;
            }

            break;
          }

          case 3:
          {
            char ch = dest[dest.length() - 1];
            if (ch != ' ')
            {
              dest += ' ';
            }
            sprintf(szDummy, "0x%02x", s[i]);
            dest += szDummy;

            unsigned long dataProcessed = i - 8;
            if (dataProcessed >= (lenId - 1))
            {
              parseState = 4;
            }
            break;
          }
          case 4:
          {
            sprintf(szDummy, " CRC:<0x%02x>", s[i]);
            dest += szDummy;
            break;
          }
          default:
            break;
        }
      }
    }
    else
    {
      for (size_t i = 0; i < s.size(); i++)
      {

        if (s[i] >= ' ')
        {
          // <todo> >= 0x80
          dest += s[i];
        }
        else
        {
          switch (s[i])
          {
            case 0x02:
              dest += "<STX>";
              break;
            case 0x03:
              dest += "<ETX>";
              break;
          }
        }
      }
    }
    if(max_strlen > 0 && dest.size() > max_strlen)
    {
      dest.resize(max_strlen);
      dest += "...";
    }

    return (dest);
  }
/*!
  \brief Converts a SOPAS command to a human readable string
  \param s: ASCII-Sopas command including 0x02 and 0x03
  \return Human readable string 0x02 and 0x02 are converted to "<STX>" and "<ETX>"
  */
\brief Converts a SOPAS command to a human readable string
\param s: ASCII-Sopas command including 0x02 and 0x03
\return Human readable string 0x02 and 0x02 are converted to "" and ""
\ brief Converts a SOPAS command to a human readable string \ param s : ASCII - Sopas command including 0x02 and 0x03 \ return Human readable string 0x02 and 0x02 are converted to " " and " "
std::string stripControl(std::vector<unsigned char> s, int max_strlen = -1)
  {
    bool isParamBinary = false;
    int spaceCnt = 0x00;
    int cnt0x02 = 0;
    for (size_t i = 0; i < s.size(); i++)
    {
      if (s[i] != 0x02)
      {
        isParamBinary = false;
      }
      else
      {
        cnt0x02++;
      }
      if (i > 4)
      {
        break;
      }
    }
    if (4 == cnt0x02)
    {
      isParamBinary = true;
    }
    std::string dest;
    if (isParamBinary == true)
    {
      int parseState = 0;
      unsigned long lenId = 0x00;
      char szDummy[255] = {0};
      for (size_t i = 0; i < s.size(); i++)
      {
        switch (parseState)
        {
          case 0:
            if (s[i] == 0x02)
            {
              dest += "<STX>";
            }
            else
            {
              dest += "?????";
            }
            if (i == 3)
            {
              parseState = 1;
            }
            break;
          case 1:
            lenId |= s[i] << (8 * (7 - i));
            if (i == 7)
            {
              sprintf(szDummy, "<Len=%04lu>", lenId);
              dest += szDummy;
              parseState = 2;
            }
            break;
          case 2:
          {
            unsigned long dataProcessed = i - 8;
            if (s[i] == ' ')
            {
              spaceCnt++;
            }
            if (spaceCnt == 2)
            {
              parseState = 3;
            }
            dest += s[i];
            if (dataProcessed >= (lenId - 1))
            {
              parseState = 4;
            }
            break;
          }
          case 3:
          {
            char ch = dest[dest.length() - 1];
            if (ch != ' ')
            {
              dest += ' ';
            }
            sprintf(szDummy, "0x%02x", s[i]);
            dest += szDummy;
            unsigned long dataProcessed = i - 8;
            if (dataProcessed >= (lenId - 1))
            {
              parseState = 4;
            }
            break;
          }
          case 4:
          {
            sprintf(szDummy, " CRC:<0x%02x>", s[i]);
            dest += szDummy;
            break;
          }
          default:
            break;
        }
      }
    }
    else
    {
      for (size_t i = 0; i < s.size(); i++)
      {
        if (s[i] >= ' ')
        {
          dest += s[i];
        }
        else
        {
          switch (s[i])
          {
            case 0x02:
              dest += "<STX>";
              break;
            case 0x03:
              dest += "<ETX>";
              break;
          }
        }
      }
    }
    if(max_strlen > 0 && dest.size() > max_strlen)
    {
      dest.resize(max_strlen);
      dest += "...";
    }
    return (dest);
  }
std :: string stripControl ( std :: vector < unsigned char > s , int max_strlen = -1 ) { bool isParamBinary = false ; int spaceCnt = 0x00 ; int cnt0x02 = 0 ; for ( size_t i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] != 0x02 ) { isParamBinary = false ; } else { cnt0x02 ++ ; } if ( i > 4 ) { break ; } } if ( 4 == cnt0x02 ) { isParamBinary = true ; } std :: string dest ; if ( isParamBinary == true ) { int parseState = 0 ; unsigned long lenId = 0x00 ; char szDummy [ 255 ] = { 0 } ; for ( size_t i = 0 ; i < s . size ( ) ; i ++ ) { switch ( parseState ) { case 0 : if ( s [ i ] == 0x02 ) { dest += " " ; } else { dest += " " ; } if ( i == 3 ) { parseState = 1 ; } break ; case 1 : lenId |= s [ i ] << ( 8 * ( 7 - i ) ) ; if ( i == 7 ) { sprintf ( szDummy , " " , lenId ) ; dest += szDummy ; parseState = 2 ; } break ; case 2 : { unsigned long dataProcessed = i - 8 ; if ( s [ i ] == ' ' ) { spaceCnt ++ ; } if ( spaceCnt == 2 ) { parseState = 3 ; } dest += s [ i ] ; if ( dataProcessed >= ( lenId - 1 ) ) { parseState = 4 ; } break ; } case 3 : { char ch = dest [ dest . length ( ) - 1 ] ; if ( ch != ' ' ) { dest += ' ' ; } sprintf ( szDummy , " " , s [ i ] ) ; dest += szDummy ; unsigned long dataProcessed = i - 8 ; if ( dataProcessed >= ( lenId - 1 ) ) { parseState = 4 ; } break ; } case 4 : { sprintf ( szDummy , " " , s [ i ] ) ; dest += szDummy ; break ; } default : break ; } } } else { for ( size_t i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] >= ' ' ) { dest += s [ i ] ; } else { switch ( s [ i ] ) { case 0x02 : dest += " " ; break ; case 0x03 : dest += " " ; break ; } } } } if ( max_strlen > 0 && dest . size ( ) > max_strlen ) { dest . resize ( max_strlen ) ; dest += " " ; } return ( dest ) ; }
\brief Converts a SOPAS command to a human readable string
\param s: ASCII-Sopas command including 0x02 and 0x03
\return Human readable string 0x02 and 0x02 are converted to "<STX>" and "<ETX>"
\ brief Converts a SOPAS command to a human readable string \ param s : ASCII - Sopas command including 0x02 and 0x03 \ return Human readable string 0x02 and 0x02 are converted to " <STX > " and " <ETX > "
// <todo> >= 0x80