Skip to content

Commit

Permalink
thermal table raw data no longer includes FW header
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Oct 1, 2020
1 parent 9d927dc commit a3cfbba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/algo/thermal-loop/l500-thermal-loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ thermal_calibration_table::thermal_calibration_table( const std::vector< byte >
int resolution )
: _resolution( resolution )
{
float const * header_ptr = (float *)( data.data() + sizeof( ivcam2::table_header ) );

auto expected_size = sizeof( ivcam2::table_header ) + sizeof( thermal_table_header )
auto expected_size = sizeof( thermal_table_header )
+ sizeof( thermal_bin ) * resolution;

if( data.size() != expected_size )
throw std::runtime_error( librealsense::to_string()
<< "data size (" << data.size()
<< ") does not meet expected size " << expected_size );

_header = *(thermal_table_header *)( header_ptr );
_header = *(thermal_table_header *)data.data();

auto data_ptr = (thermal_bin *)( data.data() + sizeof( ivcam2::table_header )
+ sizeof( thermal_table_header ) );
auto data_ptr = (thermal_bin *)( data.data() + sizeof( thermal_table_header ));
bins.assign( data_ptr, data_ptr + resolution );
}

Expand Down Expand Up @@ -86,7 +83,7 @@ double thermal_calibration_table::get_thermal_scale( double hum_temp ) const
std::vector< byte > thermal_calibration_table::build_raw_data() const
{
std::vector< float > data;
data.resize( sizeof( ivcam2::table_header ) / sizeof( float ), 0 );

data.push_back( _header.min_temp );
data.push_back( _header.max_temp );
data.push_back( _header.reference_temp );
Expand Down
3 changes: 3 additions & 0 deletions src/l500/l500-color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ namespace librealsense
register_stream_to_extrinsic_group(*_color_stream, 0);

_thermal_table = [this]() {

hwmon_response response;
auto data = read_fw_table_raw( *_hw_monitor,
algo::thermal_loop::l500::thermal_calibration_table::id,
Expand All @@ -211,6 +212,8 @@ namespace librealsense
<< algo::thermal_loop::l500::thermal_calibration_table::id );
}

if( data.size() > sizeof( table_header ))
data.erase( data.begin(), data.begin() + sizeof( table_header ) );
return algo::thermal_loop::l500::thermal_calibration_table{ data };
};

Expand Down
1 change: 0 additions & 1 deletion unit-tests/algo/thermal-loop/test-table-parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ TEST_CASE( "build_raw_data", "[thermal-loop]" )
auto raw_data = syntetic_table.build_raw_data();

std::vector< byte > raw;
raw.resize( sizeof( thermal_calibration_table::thermal_table_header ), 0 );

raw.insert( raw.end(),
(byte *)&( syntetic_table._header.min_temp ),
Expand Down

0 comments on commit a3cfbba

Please sign in to comment.