From c1518271920c3b97de714d1095b3edfad8f839c6 Mon Sep 17 00:00:00 2001 From: ohadmeir Date: Sun, 11 Feb 2024 15:20:28 +0200 Subject: [PATCH 1/2] FW logs parser should parse :f format as 32 bit float --- src/fw-logs/fw-string-formatter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fw-logs/fw-string-formatter.cpp b/src/fw-logs/fw-string-formatter.cpp index 722a25d639..861d708ab1 100644 --- a/src/fw-logs/fw-string-formatter.cpp +++ b/src/fw-logs/fw-string-formatter.cpp @@ -56,7 +56,7 @@ namespace librealsense st_regular_exp[2] << "\\{\\b(" << i << "):f\\}"; regular_exp[2] = st_regular_exp[2].str(); - st_replacement[2] << params[i]; + st_replacement[2] << *reinterpret_cast< const float * >( ¶ms[i] ); // Parse as 4 raw bytes of float replacement[2] = st_replacement[2].str(); exp_replace_map[regular_exp[2]] = replacement[2]; From a32919d94ef689f6f1d28d79381e79db043b06d0 Mon Sep 17 00:00:00 2001 From: ohadmeir Date: Mon, 12 Feb 2024 12:09:52 +0200 Subject: [PATCH 2/2] Fix PR#12652 comments --- src/fw-logs/fw-string-formatter.cpp | 16 ++++++++++++++-- src/option.cpp | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/fw-logs/fw-string-formatter.cpp b/src/fw-logs/fw-string-formatter.cpp index 861d708ab1..0946ebb385 100644 --- a/src/fw-logs/fw-string-formatter.cpp +++ b/src/fw-logs/fw-string-formatter.cpp @@ -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 + #include #include #include #include +#include using namespace std; @@ -56,7 +60,15 @@ namespace librealsense st_regular_exp[2] << "\\{\\b(" << i << "):f\\}"; regular_exp[2] = st_regular_exp[2].str(); - st_replacement[2] << *reinterpret_cast< const float * >( ¶ms[i] ); // Parse as 4 raw bytes of float + // Parse int32_t as 4 raw bytes of float + float tmp = *reinterpret_cast< const float * >( ¶ms[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]; diff --git a/src/option.cpp b/src/option.cpp index c27e7cf0d6..800b3b7cfe 100644 --- a/src/option.cpp +++ b/src/option.cpp @@ -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 );