Skip to content

Commit

Permalink
PR #12652 from OhadMeir: FW logs parser should parse :f format as 32 …
Browse files Browse the repository at this point in the history
…bit float
  • Loading branch information
OhadMeir authored Feb 12, 2024
2 parents eb7c4ed + a32919d commit faaab32
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/fw-logs/fw-string-formatter.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.
// Copyright(c) 2024 Intel Corporation. All Rights Reserved.

#include "fw-string-formatter.h"
#include "fw-logs-formating-options.h"
#include <rsutils/easylogging/easyloggingpp.h>

#include <regex>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <cmath>

using namespace std;

Expand Down Expand Up @@ -56,7 +60,15 @@ namespace librealsense

st_regular_exp[2] << "\\{\\b(" << i << "):f\\}";
regular_exp[2] = st_regular_exp[2].str();
st_replacement[2] << params[i];
// Parse int32_t as 4 raw bytes of float
float tmp = *reinterpret_cast< const float * >( &params[i] );
if( std::isfinite( tmp ) )
st_replacement[2] << tmp;
else
{
LOG_ERROR( "Expecting a number, received infinite or NaN" );
st_replacement[2] << "0x" << hex << setw( 2 ) << setfill( '0' ) << params[i];
}
replacement[2] = st_replacement[2].str();
exp_replace_map[regular_exp[2]] = replacement[2];

Expand Down
2 changes: 1 addition & 1 deletion src/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void gated_by_value_option::set( float requested_option_value )
auto wanted_gate_value = std::get< 1 >( gate );
auto current_gate_value = gating_option->query();
if( current_gate_value != wanted_gate_value )
throw std::runtime_error( std::get< 2 >( gate ) );
throw librealsense::invalid_value_exception( std::get< 2 >( gate ) );
}

_proxy->set( requested_option_value );
Expand Down

0 comments on commit faaab32

Please sign in to comment.