Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/ds/d500/d500-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ namespace librealsense
_depth_stream(new stream(RS2_STREAM_DEPTH)),
_left_ir_stream(new stream(RS2_STREAM_INFRARED, 1)),
_right_ir_stream(new stream(RS2_STREAM_INFRARED, 2)),
_color_stream(nullptr)
_color_stream(nullptr),
_hw_monitor_response(std::make_shared<ds::d500_hwmon_response>())
{
_depth_device_idx
= add_sensor( create_depth_device( dev_info->get_context(), dev_info->get_group().uvc_devices ) );
Expand All @@ -407,13 +408,13 @@ namespace librealsense
_hw_monitor = std::make_shared<hw_monitor_extended_buffers>(
std::make_shared<locked_transfer>(
std::make_shared<command_transfer_over_xu>( *raw_sensor, depth_xu, DS5_HWMONITOR ),
raw_sensor), std::make_shared<ds::d500_hwmon_response>());
raw_sensor), _hw_monitor_response);
}
else
{
_hw_monitor = std::make_shared< hw_monitor_extended_buffers >(
std::make_shared< locked_transfer >( get_backend()->create_usb_device( group.usb_devices.front() ),
raw_sensor ), std::make_shared<ds::d500_hwmon_response>());
raw_sensor ), _hw_monitor_response);
}

_ds_device_common = std::make_shared<ds_device_common>(this, _hw_monitor);
Expand Down Expand Up @@ -455,8 +456,19 @@ namespace librealsense
bool advanced_mode = false;
bool usb_modality = true;
group_multiple_fw_calls(depth_sensor, [&]() {

// D500 device can get enumerated before the whole HW in the camera is ready.
// Since GVD gather all information from all the HW, it might need some more time to finish all hand shakes.
// on this case it will return HW_NOT_READY error code.
// Note: D500 error codes list is different than D400.

const std::set< int32_t > gvd_retry_errors{ _hw_monitor_response->HW_NOT_READY };

_hw_monitor->get_gvd( gvd_buff.size(),
gvd_buff.data(),
ds::fw_cmd::GVD,
&gvd_retry_errors );

_hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), ds::fw_cmd::GVD);
get_gvd_details(gvd_buff, &gvd_parsed_fields);

_device_capabilities = ds_caps::CAP_ACTIVE_PROJECTOR | ds_caps::CAP_RGB_SENSOR | ds_caps::CAP_IMU_SENSOR |
Expand Down
2 changes: 2 additions & 0 deletions src/ds/d500/d500-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace librealsense

d500_device( std::shared_ptr< const d500_info > const & );

std::shared_ptr<ds::d500_hwmon_response> _hw_monitor_response;

std::vector<uint8_t> send_receive_raw_data(const std::vector<uint8_t>& input) override;

std::vector<uint8_t> build_command(uint32_t opcode,
Expand Down
31 changes: 29 additions & 2 deletions src/hw-monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright(c) 2015 Intel Corporation. All Rights Reserved.
#include "hw-monitor.h"
#include "types.h"
#include <rsutils/string/from.h>
#include <iomanip>
#include <limits>
#include <sstream>
Expand Down Expand Up @@ -226,10 +227,36 @@ namespace librealsense
}


void hw_monitor::get_gvd(size_t sz, unsigned char* gvd, uint8_t gvd_cmd) const
void hw_monitor::get_gvd( size_t sz,
unsigned char * gvd,
uint8_t gvd_cmd,
const std::set< int32_t > * retry_error_codes ) const
{
command command(gvd_cmd);
auto data = send(command);
hwmon_response_type response;
auto data = send( command, &response );
// If we get an error code that match to the error code defined as require retry,
// we will retry the command until it succeed or we reach a timeout
bool should_retry = retry_error_codes && retry_error_codes->find( response ) != retry_error_codes->end();
if( should_retry )
{
constexpr size_t RETRIES = 50;
for( int i = 0; i < RETRIES; ++i )
{
LOG_WARNING( "GVD not ready - retrying GET_GVD command" );
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
data = send( command, &response );
if( response == _hwmon_response->success_value() )
break;
// If we failed after 'RETRIES' retries or it is less `RETRIES` and the error
// code is not in the retry list than , raise an exception
if( i >= ( RETRIES - 1 ) || retry_error_codes->find( response ) == retry_error_codes->end() )
throw io_exception( rsutils::string::from()
<< "error in querying GVD, error:"
<< _hwmon_response->hwmon_error2str( response ) );

}
}
auto minSize = std::min(sz, data.size());
std::memcpy( gvd, data.data(), minSize );
}
Expand Down
5 changes: 4 additions & 1 deletion src/hw-monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ namespace librealsense
uint8_t const * data = nullptr,
size_t dataLength = 0);

void get_gvd(size_t sz, unsigned char* gvd, uint8_t gvd_cmd) const;
void get_gvd( size_t sz,
unsigned char * gvd,
uint8_t gvd_cmd,
const std::set< int32_t > * retry_error_codes = nullptr ) const;

template<typename T>
std::string get_firmware_version_string( const std::vector< uint8_t > & buff,
Expand Down