Skip to content

Commit

Permalink
PR IntelRealSense#13076 from Eran: don't start backend if device-mask…
Browse files Browse the repository at this point in the history
… specifies sw-only
  • Loading branch information
maloel authored Jun 24, 2024
2 parents ba6bbe2 + bc8594f commit df33071
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 23 deletions.
13 changes: 8 additions & 5 deletions src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ namespace librealsense {

void context::create_factories( std::shared_ptr< context > const & sptr )
{
_factories.push_back( std::make_shared< backend_device_factory >(
sptr,
[this]( std::vector< std::shared_ptr< device_info > > const & removed,
std::vector< std::shared_ptr< device_info > > const & added )
{ invoke_devices_changed_callbacks( removed, added ); } ) );
if( 0 == ( get_device_mask() & RS2_PRODUCT_LINE_SW_ONLY ) )
{
_factories.push_back( std::make_shared< backend_device_factory >(
sptr,
[this]( std::vector< std::shared_ptr< device_info > > const & removed,
std::vector< std::shared_ptr< device_info > > const & added )
{ invoke_devices_changed_callbacks( removed, added ); } ) );
}

#ifdef BUILD_WITH_DDS
_factories.push_back( std::make_shared< rsdds_device_factory >(
Expand Down
2 changes: 1 addition & 1 deletion unit-tests/dds/librs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _device_change_callback( info ):
_devices_updated.set()


def wait_for_devices( context, mask, n=1, timeout=3, throw=None ):
def wait_for_devices( context, mask=product_line.any, n=1, timeout=3, throw=None ):
"""
Since DDS devices may take time to be recognized and then initialized, we try over time:
Expand Down
23 changes: 15 additions & 8 deletions unit-tests/dds/test-librs-connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,59 @@
remote.run( 'instance2 = broadcast_device( d405, d405.device_info )' )

# Create context after remote device is ready to test discovery on start-up
context = rs.context( { 'dds': { 'enabled': True, 'domain': 123, 'participant': 'librs' }} )
context = rs.context( {
'dds': {
'enabled': True,
'domain': 123,
'participant': 'librs'
},
'device-mask': rs.only_sw_devices
} )
# The DDS devices take time to be recognized and we just created the context; we
# should not see them yet!
#test.check( len( context.query_devices( rs.only_sw_devices )) != 2 )
# Wait for them
rs.wait_for_devices( context, rs.only_sw_devices, n=2. )
rs.wait_for_devices( context, n=2. )
#
#############################################################################################
#
with test.closure( "Start a third", on_fail=test.ABORT ):
remote.run( 'instance3 = broadcast_device( d455, d455.device_info )' )
rs.wait_for_devices( context, rs.only_sw_devices, n=3. )
rs.wait_for_devices( context, n=3. )
#
#############################################################################################
#
with test.closure( "Close the first", on_fail=test.ABORT ):
rs._devices_updated.clear()
remote.run( 'close_server( instance )' )
remote.run( 'instance = None', timeout=1 )
rs.wait_for_devices( context, rs.only_sw_devices, n=2. )
rs.wait_for_devices( context, n=2. )
#
#############################################################################################
#
with test.closure( "Add a fourth", on_fail=test.ABORT ):
remote.run( 'instance4 = broadcast_device( d435i, d435i.device_info )' )
rs.wait_for_devices( context, rs.only_sw_devices, n=3. )
rs.wait_for_devices( context, n=3. )
#
#############################################################################################
#
with test.closure( "Close the second", on_fail=test.ABORT ):
remote.run( 'close_server( instance2 )' )
remote.run( 'instance2 = None', timeout=1 )
rs.wait_for_devices( context, rs.only_sw_devices, n=2. )
rs.wait_for_devices( context, n=2. )
#
#############################################################################################
#
with test.closure( "Close the third", on_fail=test.ABORT ):
remote.run( 'close_server( instance3 )' )
remote.run( 'instance2 = None', timeout=1 )
rs.wait_for_devices( context, rs.only_sw_devices, n=1. )
rs.wait_for_devices( context, n=1. )
#
#############################################################################################
#
with test.closure( "Close the last", on_fail=test.ABORT ):
remote.run( 'close_server( instance4 )' )
rs.wait_for_devices( context, rs.only_sw_devices, n=0. )
rs.wait_for_devices( context, n=0. )
#
#############################################################################################

Expand Down
15 changes: 11 additions & 4 deletions unit-tests/dds/test-librs-device-properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
rs.log_to_console( rs.log_severity.debug )
from time import sleep

context = rs.context( { 'dds': { 'enabled': True, 'domain': 123, 'participant': 'device-properties-client' }} )
context = rs.context( {
'dds': {
'enabled': True,
'domain': 123,
'participant': 'device-properties-client'
},
'device-mask': rs.only_sw_devices
} )


import os.path
Expand All @@ -29,7 +36,7 @@
#
with test.closure( "Test D435i" ):
remote.run( 'instance = broadcast_device( d435i, d435i.device_info )' )
dev = rs.wait_for_devices( context, rs.only_sw_devices, n=1. )
dev = rs.wait_for_devices( context, n=1. )
test.check_equal( dev.get_info( rs.camera_info.name ), d435i.device_info.name )
test.check_equal( dev.get_info( rs.camera_info.serial_number ), d435i.device_info.serial )
test.check_equal( dev.get_info( rs.camera_info.physical_port ), d435i.device_info.topic_root )
Expand Down Expand Up @@ -60,7 +67,7 @@
#
with test.closure( "Test D405" ):
remote.run( 'instance = broadcast_device( d405, d405.device_info )' )
dev = rs.wait_for_devices( context, rs.only_sw_devices, n=1. )
dev = rs.wait_for_devices( context, n=1. )
test.check_equal( dev.get_info( rs.camera_info.name ), d405.device_info.name )
test.check_equal( dev.get_info( rs.camera_info.serial_number ), d405.device_info.serial )
test.check_equal( dev.get_info( rs.camera_info.physical_port ), d405.device_info.topic_root )
Expand All @@ -78,7 +85,7 @@
#
with test.closure( "Test D455" ):
remote.run( 'instance = broadcast_device( d455, d455.device_info )' )
dev = rs.wait_for_devices( context, rs.only_sw_devices, n=1. )
dev = rs.wait_for_devices( context, n=1. )
test.check_equal( dev.get_info( rs.camera_info.name ), d455.device_info.name )
test.check_equal( dev.get_info( rs.camera_info.serial_number ), d455.device_info.serial )
test.check_equal( dev.get_info( rs.camera_info.physical_port ), d455.device_info.topic_root )
Expand Down
11 changes: 8 additions & 3 deletions unit-tests/dds/test-librs-extrinsics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
rs.log_to_console( rs.log_severity.debug )
from time import sleep

context = rs.context( { 'dds': { 'enabled': True, 'domain': 123 }} )
only_sw_devices = int(rs.product_line.sw_only) | int(rs.product_line.any_intel)
context = rs.context( {
'dds': {
'enabled': True,
'domain': 123
},
'device-mask': rs.only_sw_devices
} )

import os.path
cwd = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -27,7 +32,7 @@
try:
remote.run( 'instance = broadcast_device( d435i, d435i.device_info )' )
n_devs = 0
for dev in rs.wait_for_devices( context, only_sw_devices ):
for dev in rs.wait_for_devices( context ):
n_devs += 1
test.check_equal( n_devs, 1 )

Expand Down
11 changes: 9 additions & 2 deletions unit-tests/dds/test-librs-formats-conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
rs.log_to_console( rs.log_severity.debug )
log.nested = 'C '

context = rs.context( { 'dds': { 'enabled': True, 'domain': 123, 'participant': 'test-formats-conversion' }} )
context = rs.context( {
'dds': {
'enabled': True,
'domain': 123,
'participant': 'test-formats-conversion'
},
'device-mask': rs.only_sw_devices
} )

import os.path
cwd = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -23,7 +30,7 @@
#
with test.closure( "Test setup", on_fail=test.ABORT ):
remote.run( 'create_server()' )
dev = rs.wait_for_devices( context, rs.only_sw_devices, n=1. )
dev = rs.wait_for_devices( context, n=1. )
sensors = {sensor.get_info( rs.camera_info.name ) : sensor for sensor in dev.query_sensors()}
#
#############################################################################################
Expand Down

0 comments on commit df33071

Please sign in to comment.