Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Handle PR#14228 comments
  • Loading branch information
OhadMeir committed Aug 27, 2025
commit ed9bc411395fa9813b426d89bec65c8dc1942aee
45 changes: 19 additions & 26 deletions common/dds-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ dds_model::dds_model( rs2::device dev )
{
if( check_DDS_support() )
{
get_eth_config();
reset_to_current_values();
load_eth_config_from_device();
reset_to_current_device_values();
_dds_supported = true;
}
}

void dds_model::get_eth_config()
void dds_model::load_eth_config_from_device()
{
_domain_current = _eth_device.get_dds_domain();
_link_priority_current = _eth_device.get_link_priority();
Expand All @@ -49,7 +49,7 @@ void dds_model::get_eth_config()
_link_speed_read_only = _eth_device.get_link_speed();
}

void dds_model::set_eth_config( std::string & error_message, bool reset_to_default )
void dds_model::save_eth_config_in_device( std::string & error_message, bool reset_to_default )
{
try
{
Expand Down Expand Up @@ -89,21 +89,14 @@ void dds_model::set_eth_config( std::string & error_message, bool reset_to_defau
}
}

bool dds_model::supports_DDS()
{
return _dds_supported;
}

rs2::dds_model::priority dds_model::classifyPriority( rs2_eth_link_priority pr )
rs2::dds_model::priority dds_model::classify_priority( rs2_eth_link_priority pr ) const
{
if( pr == RS2_LINK_PRIORITY_USB_ONLY || pr == RS2_LINK_PRIORITY_USB_FIRST )
{
return priority::USB_FIRST;
}
else if( pr == RS2_LINK_PRIORITY_ETH_ONLY || pr == RS2_LINK_PRIORITY_ETH_FIRST )
{

if( pr == RS2_LINK_PRIORITY_ETH_ONLY || pr == RS2_LINK_PRIORITY_ETH_FIRST )
return priority::ETH_FIRST;
}

return priority::DYNAMIC;
}

Expand All @@ -112,7 +105,7 @@ bool dds_model::check_DDS_support()
return _eth_device.supports_eth_config();
}

void dds_model::reset_to_current_values()
void dds_model::reset_to_current_device_values()
{
_domain_to_set = _domain_current;
_link_priority_to_set = _link_priority_current;
Expand All @@ -137,7 +130,7 @@ bool dds_model::has_changed_values() const
_mtu_to_set != _mtu_current || _tx_delay_to_set != _tx_delay_current;
}

void rs2::dds_model::ipInputText( std::string label, ip_address & ip )
void rs2::dds_model::ip_input_text( std::string label, ip_address & ip ) const
{
char buffer[16];
std::string ip_str = ip.to_string();
Expand Down Expand Up @@ -167,8 +160,8 @@ void dds_model::render_dds_config_window( ux_window & window, std::string & erro
{
try
{
get_eth_config();
reset_to_current_values();
load_eth_config_from_device();
reset_to_current_device_values();
ImGui::OpenPopup( window_name );
}
catch( std::exception e )
Expand Down Expand Up @@ -241,7 +234,7 @@ void dds_model::render_dds_config_window( ux_window & window, std::string & erro

if( ImGui::CollapsingHeader( "Connection Priority" ) )
{
priority connection_priority = classifyPriority( _link_priority_to_set );
priority connection_priority = classify_priority( _link_priority_to_set );
ImGui::Text( "Select connection priority:" );
ImGui::RadioButton( "Ethernet First", reinterpret_cast< int * >( &connection_priority ), 0 );
if( static_cast< int >( connection_priority ) == 0 )
Expand Down Expand Up @@ -286,16 +279,16 @@ void dds_model::render_dds_config_window( ux_window & window, std::string & erro
ImGui::Text( "Static IP Address" );
ImGui::SameLine();
float textbox_align = ImGui::GetCursorPosX();
ipInputText( "Static IP Address", _ip_to_set );
ip_input_text( "Static IP Address", _ip_to_set );
ImGui::Text( "Subnet Mask" );
ImGui::SameLine();
ImGui::SetCursorPosX( textbox_align );
bool maskStylePushed = false;
ipInputText( "Subnet Mask", _netmask_to_set );
ip_input_text( "Subnet Mask", _netmask_to_set );
ImGui::Text( "Gateway" );
ImGui::SameLine();
ImGui::SetCursorPosX( textbox_align );
ipInputText( "Gateway", _gateway_to_set );
ip_input_text( "Gateway", _gateway_to_set );
}
else
{
Expand Down Expand Up @@ -342,7 +335,7 @@ void dds_model::render_dds_config_window( ux_window & window, std::string & erro
ImGui::Checkbox( "No Reset after changes", &_no_reset );
if( ImGui::Button( "Revert changes" ) )
{
reset_to_current_values();
reset_to_current_device_values();
}
if( ImGui::IsItemHovered() )
{
Expand All @@ -369,7 +362,7 @@ void dds_model::render_dds_config_window( ux_window & window, std::string & erro
ImGui::SameLine();
if( ImGui::Button( "Factory Reset", ImVec2( button_width, 25 ) ) )
{
set_eth_config( error_message, true );
save_eth_config_in_device( error_message, true );
close_window();
}
if( ImGui::IsItemHovered() )
Expand All @@ -383,7 +376,7 @@ void dds_model::render_dds_config_window( ux_window & window, std::string & erro
{
if( ImGui::ButtonEx( "Apply", ImVec2( button_width, 25 ) ) )
{
set_eth_config( error_message );
save_eth_config_in_device( error_message );
close_window();
};
},
Expand Down
13 changes: 6 additions & 7 deletions common/dds-model.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ namespace rs2

void close_window() { ImGui::CloseCurrentPopup(); }

bool supports_DDS();

bool supports_DDS() const { return _dds_supported; }

private:
enum priority
Expand Down Expand Up @@ -54,12 +53,12 @@ namespace rs2
bool _no_reset;
bool _dds_supported;

void get_eth_config();
void set_eth_config( std::string & error_message, bool reset_to_default = false );
void ipInputText( std::string label, rsutils::type::ip_address & ip );
priority classifyPriority( rs2_eth_link_priority pr );
void load_eth_config_from_device();
void save_eth_config_in_device( std::string & error_message, bool reset_to_default = false );
void ip_input_text( std::string label, rsutils::type::ip_address & ip ) const;
priority classify_priority( rs2_eth_link_priority pr ) const;
bool check_DDS_support();
void reset_to_current_values();
void reset_to_current_device_values();
bool has_changed_values() const;
};
}
2 changes: 1 addition & 1 deletion examples/eth-config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2025 RealSense, Inc. All Rights Reserved.

cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.10)

project( rs-eth-config )

Expand Down
14 changes: 7 additions & 7 deletions include/librealsense2/h/rs_eth_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int rs2_supports_eth_config( const rs2_device * device, rs2_error ** error );
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return Current Ethernet link speed Mbps. 0 if link is not available.
*/
int rs2_get_link_speed( const rs2_device * device, rs2_error ** error );
unsigned int rs2_get_link_speed( const rs2_device * device, rs2_error ** error );

/**
* Get link priority
Expand Down Expand Up @@ -86,17 +86,17 @@ unsigned int rs2_get_link_timeout( const rs2_device * device, rs2_error ** error
void rs2_set_link_timeout( const rs2_device * device, unsigned int timeout, rs2_error ** error );

/**
* Get current DDS domain (0-232)
* Get current DDS domain id (0-232) used when connected through Ethernet
* \param[in] device RealSense device
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return Current link timeout in milliseconds
* \return Current DDS domain id used when connected through Ethernet
*/
unsigned int rs2_get_dds_domain( const rs2_device * device, rs2_error ** error );

/**
* Set DDS domain to use
* Set DDS domain id to use when connected through Ethernet
* \param[in] device RealSense device
* \param[in] domain DDS domain to use (0-232)
* \param[in] domain DDS domain id to use (0-232)
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
*/
void rs2_set_dds_domain( const rs2_device * device, unsigned int domain, rs2_error ** error );
Expand All @@ -122,7 +122,7 @@ void rs2_set_ip_address( const rs2_device * device, const rs2_ip_address ip, rs2
* Get network mask
* \param[in] device RealSense device
* \param[out] configured_netmask Configured network mask to populate
* \param[out] actual_netmask Actual network mask to populate. Might be different from configured_ip if DHCP is enabled
* \param[out] actual_netmask Actual network mask to populate. Might be different from configured_netmask if DHCP is enabled
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
*/
void rs2_get_netmask( const rs2_device * device, rs2_ip_address configured_netmask, rs2_ip_address actual_netmask, rs2_error ** error );
Expand All @@ -139,7 +139,7 @@ void rs2_set_netmask( const rs2_device * device, const rs2_ip_address netmask, r
* Get gateway address
* \param[in] device RealSense device
* \param[out] configured_gateway Configured gateway address to populate
* \param[out] actual_gateway Actual gateway address to populate. Might be different from configured_ip if DHCP is enabled
* \param[out] actual_gateway Actual gateway address to populate. Might be different from configured_gateway if DHCP is enabled
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
*/
void rs2_get_gateway( const rs2_device * device, rs2_ip_address configured_gateway, rs2_ip_address actual_gateway, rs2_error ** error );
Expand Down
1 change: 1 addition & 0 deletions include/librealsense2/h/rs_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ typedef enum rs2_extension
RS2_EXTENSION_SAFETY_SENSOR,
RS2_EXTENSION_DEPTH_MAPPING_SENSOR,
RS2_EXTENSION_LABELED_POINTS,
RS2_EXTENSION_ETH_CONFIG,
RS2_EXTENSION_COUNT
} rs2_extension;
const char* rs2_extension_type_to_string(rs2_extension type);
Expand Down
10 changes: 5 additions & 5 deletions include/librealsense2/hpp/rs_eth_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ namespace rs2
eth_config_device( rs2::device d ) : device( d.get() )
{
rs2_error * e = nullptr;
// Ethernet configuration is supported through HWM commands, must be extensible to RS2_EXTENSION_DEBUG
if( rs2_is_device_extendable_to( _dev.get(), RS2_EXTENSION_DEBUG, &e ) == 0 && ! e )
_dev.reset();
else if( ! rs2_supports_eth_config( _dev.get(), &e ) && ! e )
bool extendable = rs2_is_device_extendable_to( _dev.get(), RS2_EXTENSION_ETH_CONFIG, &e ) && ! e;
if( ! extendable || ! rs2_supports_eth_config( _dev.get(), &e ) || e )
_dev.reset();
error::handle( e );
}
Expand All @@ -36,6 +34,8 @@ namespace rs2
*/
bool supports_eth_config() const
{
if( ! _dev )
return false; // Was reset in constructor because not supporting Ethernet configuration
rs2_error * e = nullptr;
auto result = rs2_supports_eth_config( _dev.get(), &e );
error::handle( e );
Expand All @@ -45,7 +45,7 @@ namespace rs2
/**
* Get Ethernet link speed, 0 if not linked
*/
int get_link_speed() const
uint32_t get_link_speed() const
{
rs2_error * e = nullptr;
auto result = rs2_get_link_speed( _dev.get(), &e );
Expand Down
1 change: 0 additions & 1 deletion include/librealsense2/hpp/rs_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "../h/rs_record_playback.h"
#include "../h/rs_sensor.h"
#include "../h/rs_pipeline.h"
#include "../h/rs_eth_config.h"

#include <string>
#include <vector>
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ target_sources(${LRS_TARGET}
"${CMAKE_CURRENT_LIST_DIR}/points.cpp"
"${CMAKE_CURRENT_LIST_DIR}/labeled-points.cpp"
"${CMAKE_CURRENT_LIST_DIR}/to-string.cpp"
"${CMAKE_CURRENT_LIST_DIR}/eth-config-device.cpp"

"${CMAKE_CURRENT_LIST_DIR}/algo.h"
"${CMAKE_CURRENT_LIST_DIR}/api.h"
Expand Down Expand Up @@ -187,6 +188,7 @@ target_sources(${LRS_TARGET}
"${CMAKE_CURRENT_LIST_DIR}/feature-interface.h"
"${CMAKE_CURRENT_LIST_DIR}/synthetic-options-watcher.h"
"${CMAKE_CURRENT_LIST_DIR}/synthetic-options-watcher.cpp"
"${CMAKE_CURRENT_LIST_DIR}/eth-config-device.h"
)

if(BUILD_WITH_DDS)
Expand Down
11 changes: 11 additions & 0 deletions src/dds/rs-dds-device-proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
register_info( RS2_CAMERA_INFO_CAMERA_LOCKED, j.nested( "locked" ).default_value( true ) ? "YES" : "NO" );
register_info(RS2_CAMERA_INFO_CONNECTION_TYPE, "DDS" );

eth_config_device::init( static_cast< debug_interface * >( this ) ); // Call after registering device info

// Assumes dds_device initialization finished
struct sensor_info
{
Expand Down Expand Up @@ -834,5 +836,14 @@ std::vector< sensor_interface const * > dds_device_proxy::get_serializable_senso
return sensors;
}

bool dds_device_proxy::supports_ethernet_configuration()
{
std::string dev_name = get_info( RS2_CAMERA_INFO_NAME ); // Info supported, registered at constructor
if( dev_name.find( "D555" ) == std::string::npos ) // Currently only D555 devices support eth_config
return false;

return eth_config_device::supports_ethernet_configuration();
}


} // namespace librealsense
8 changes: 6 additions & 2 deletions src/dds/rs-dds-device-proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "rsdds-serializable.h"
#include <src/auto-calibrated-proxy.h>
#include <src/device-calibration.h>
#include <src/eth-config-device.h>

#include <rsutils/json-fwd.h>
#include <memory>
Expand Down Expand Up @@ -48,6 +49,7 @@ class dds_device_proxy
, public dds_serializable
, public auto_calibrated_proxy
, public calibration_change_device
, public eth_config_device
{
std::shared_ptr< realdds::dds_device > _dds_dev;
std::map< std::string, std::vector< std::shared_ptr< stream_profile_interface > > > _stream_name_to_profiles;
Expand Down Expand Up @@ -117,8 +119,10 @@ class dds_device_proxy
device_interface const & get_serializable_device() const override { return *this; }
std::vector< sensor_interface * > get_serializable_sensors() override;
std::vector< sensor_interface const * > get_serializable_sensors() const override;
};


// eth_config_device
public:
bool supports_ethernet_configuration() override;
Comment thread
remibettan marked this conversation as resolved.
};

} // namespace librealsense
8 changes: 5 additions & 3 deletions src/ds/d500/d500-factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <src/core/matcher-factory.h>
#include <src/proc/color-formats-converter.h>
#include <src/core/advanced_mode.h>
#include <src/eth-config-device.h>

#include "d500-info.h"
#include "d500-private.h"
Expand Down Expand Up @@ -163,6 +164,7 @@ class d555_device
, public d500_motion
, public ds_advanced_mode_base
, public extended_firmware_logger_device
, public eth_config_device
{
public:
d555_device( std::shared_ptr< const d500_info > dev_info )
Expand All @@ -173,10 +175,10 @@ class d555_device
, d500_color( dev_info, RS2_FORMAT_YUYV )
, d500_motion( dev_info )
, ds_advanced_mode_base( d500_device::_hw_monitor, get_depth_sensor() )
, extended_firmware_logger_device( dev_info,
d500_device::_hw_monitor,
get_firmware_logs_command() )
, extended_firmware_logger_device( dev_info, d500_device::_hw_monitor, get_firmware_logs_command() )
{
eth_config_device::init( static_cast< debug_interface * >( this ) );

auto & depth_sensor = get_depth_sensor();
group_multiple_fw_calls(depth_sensor, [&]()
{
Expand Down
Loading
Loading