Skip to content

Commit 1e34346

Browse files
authored
PR #13969 from OhadMeir/R/256: Cherry Pick PR #13968 from OhadMeir: Handle DDS devices in Recovery Mode
2 parents e70fb27 + 977e345 commit 1e34346

File tree

5 files changed

+63
-41
lines changed

5 files changed

+63
-41
lines changed

common/dds-model.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,25 @@ bool dds_model::check_DDS_support()
9999
{
100100
if( _device.is< rs2::debug_protocol >() )
101101
{
102-
auto dev = debug_protocol( _device );
103-
auto cmd = dev.build_command( GET_ETH_CONFIG, CURRENT_VALUES );
104-
auto data = dev.send_and_receive_raw_data( cmd );
105-
int32_t const & code = *reinterpret_cast< int32_t const * >( data.data() );
106-
if( code == GET_ETH_CONFIG )
107-
return true;
102+
if( _device.supports( RS2_CAMERA_INFO_NAME ) )
103+
{
104+
std::string name = _device.get_info( RS2_CAMERA_INFO_NAME );
105+
if( name.find( "Recovery" ) != std::string::npos )
106+
return false; // Recovery devices don't support HWM.
107+
}
108+
109+
try
110+
{
111+
auto dev = debug_protocol( _device );
112+
auto cmd = dev.build_command( GET_ETH_CONFIG, CURRENT_VALUES );
113+
auto data = dev.send_and_receive_raw_data( cmd );
114+
int32_t const & code = *reinterpret_cast< int32_t const * >( data.data() );
115+
if( code == GET_ETH_CONFIG )
116+
return true;
117+
}
118+
catch( ... )
119+
{
120+
}
108121
}
109122

110123
return false;

src/dds/rs-dds-device-proxy.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
151151
, _dds_dev( dev )
152152
{
153153
//LOG_DEBUG( "=====> dds-device-proxy " << this << " created on top of dds-device " << _dds_dev.get() );
154-
register_info( RS2_CAMERA_INFO_NAME, dev->device_info().name() );
154+
std::string suffix = dev->device_info().is_recovery() ? " Recovery" : "";
155+
register_info( RS2_CAMERA_INFO_NAME, dev->device_info().name() + suffix );
155156
register_info( RS2_CAMERA_INFO_PHYSICAL_PORT, dev->device_info().topic_root() );
156157
register_info( RS2_CAMERA_INFO_PRODUCT_ID, "DDS" );
157158

third-party/realdds/include/realdds/topics/device-info-msg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class device_info
2525
rsutils::json const & to_json() const;
2626
static device_info from_json( rsutils::json const & );
2727

28+
bool is_recovery() const;
29+
2830
// Substring of information already stored in the device-info that can be used to print the device 'name'.
2931
// (mostly for use with debug messages)
3032
rsutils::string::slice debug_name() const;

third-party/realdds/src/topics/device-info-msg.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ void device_info::set_serial_number( std::string const & v )
7373
}
7474

7575

76+
bool device_info::is_recovery() const
77+
{
78+
return _json.nested( key::recovery, &rsutils::json::is_boolean ).default_value( false );
79+
}
80+
81+
7682
rsutils::string::slice device_info::debug_name() const
7783
{
7884
return device_name_from_root( topic_root() );

tools/dds/dds-config/rs-dds-config.cpp

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ bool find_device( rs2::context const & ctx,
132132
eth_config & config,
133133
rs2::cli::value< std::string > & sn_arg,
134134
bool const golden,
135-
std::set< std::string > & devices_looked_at )
135+
std::set< std::string > & devices_looked_at,
136+
bool & recovery )
136137
{
137138
auto device_list = ctx.query_devices();
138139
auto const n_devices = device_list.size();
@@ -148,7 +149,11 @@ bool find_device( rs2::context const & ctx,
148149
if( ! devices_looked_at.insert( sn ).second )
149150
continue; // insert failed: device was already looked at
150151
LOG_DEBUG( "trying " << describe_device( possible_device ) );
151-
config = get_eth_config( possible_device, golden );
152+
std::string name = possible_device.get_info( RS2_CAMERA_INFO_NAME );
153+
if( name.find( "Recovery" ) != std::string::npos )
154+
recovery = true;
155+
else
156+
config = get_eth_config( possible_device, golden );
152157
if( device )
153158
more_than_one_device = true;
154159
list_device( device = possible_device );
@@ -228,24 +233,49 @@ try
228233
}
229234
return EXIT_SUCCESS;
230235
}
236+
237+
// Enable DDS in future runs
238+
auto const filename = rsutils::os::get_special_folder( rsutils::os::special_folder::app_data ) + RS2_CONFIG_FILENAME;
239+
auto config = rsutils::json_config::load_from_file( filename );
240+
if( ! config )
241+
config = json::object();
242+
243+
if( ! config.nested( "context", "dds", "enabled" ).default_value( false ) )
244+
{
245+
config["context"]["dds"]["enabled"] = true;
246+
try
247+
{
248+
std::ofstream out( filename );
249+
out << std::setw( 2 ) << config;
250+
out.close();
251+
INFO( "DDS is now enabled by default in " RS2_CONFIG_FILENAME );
252+
}
253+
catch( std::exception const & e )
254+
{
255+
std::cout << "-W- FAILED to enable DDS by default: " << e.what() << std::endl;
256+
}
257+
}
231258

232259
bool const golden = golden_arg.isSet();
233260

234261
// Create a RealSense context and look for a device
235-
settings["dds"]["enabled"] = true;
236262
rs2::context ctx( settings.dump() );
237263

238264
rs2::device device;
239265
eth_config current;
240266
std::set< std::string > devices_looked_at;
241-
if( ! find_device( ctx, device, current, sn_arg, golden, devices_looked_at ) )
267+
bool recovery = false;
268+
if( ! find_device( ctx, device, current, sn_arg, golden, devices_looked_at, recovery ) )
242269
{
243270
if( sn_arg.isSet() )
244271
throw std::runtime_error( "Device not found or does not support Eth" );
245272

246273
throw std::runtime_error( "No device found supporting Eth" );
247274
}
248275

276+
if( recovery )
277+
throw std::runtime_error( "Recovery devices don't support Ethernet params configuration" );
278+
249279
eth_config requested( current );
250280
if( golden || factory_reset_arg.isSet() || reset_arg.isSet() )
251281
{
@@ -357,36 +387,6 @@ try
357387
else if( requested == current )
358388
{
359389
LOG_DEBUG( "nothing to do" );
360-
361-
// When running with no arguments, and DDS is disabled, and we actually find a DDS device, we automatically
362-
// enable DDS in future runs:
363-
if( device.get_type() == "DDS" )
364-
{
365-
auto const filename
366-
= rsutils::os::get_special_folder( rsutils::os::special_folder::app_data ) + RS2_CONFIG_FILENAME;
367-
auto config = rsutils::json_config::load_from_file( filename );
368-
369-
bool enabled;
370-
if( ! config.nested( "context", "dds", "enabled" ).get_ex( enabled ) )
371-
{
372-
config["context"]["dds"]["enabled"] = true;
373-
try
374-
{
375-
std::ofstream out( filename );
376-
out << std::setw( 2 ) << config;
377-
out.close();
378-
INFO( "DDS is now enabled by default in " RS2_CONFIG_FILENAME );
379-
}
380-
catch( std::exception const & e )
381-
{
382-
std::cout << "-W- " << "FAILED to enable DDS by default: " << e.what() << std::endl;
383-
}
384-
}
385-
else
386-
{
387-
LOG_DEBUG( "'dds/enabled' was pre-set in configuration file (to " << enabled << "); no changes made" );
388-
}
389-
}
390390
}
391391
else
392392
{

0 commit comments

Comments
 (0)