From e72549245b52fbf69efdb15470fc9eb333f53e1d Mon Sep 17 00:00:00 2001 From: Eran Date: Mon, 27 Feb 2023 08:21:47 +0200 Subject: [PATCH 1/4] add third-party/realdds to pr_check.sh script --- scripts/pr_check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pr_check.sh b/scripts/pr_check.sh index 8ab2c29f23..cd5e848d73 100755 --- a/scripts/pr_check.sh +++ b/scripts/pr_check.sh @@ -121,12 +121,12 @@ if [[ $1 == *"help"* ]]; then echo " --fix Try to auto-fix defects" exit 0 fi - + cd .. check_folder include $1 check_folder src $1 check_folder examples $1 -check_folder third-party/libtm $1 +check_folder third-party/realdds $1 check_folder tools $1 cd scripts From a68084e9d7b9e3760c73c865c7145ff8f7b6c55a Mon Sep 17 00:00:00 2001 From: Eran Date: Mon, 27 Feb 2023 08:22:07 +0200 Subject: [PATCH 2/4] fix cppcheck warnings in dds code --- src/context.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/context.cpp b/src/context.cpp index 0ef0b5712d..d64081c5d5 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -773,7 +773,7 @@ namespace librealsense to_rs2_video_stream( rs2_stream const stream_type, sid_index const & sidx, std::shared_ptr< realdds::dds_video_stream_profile > const & profile, - const std::set< realdds::video_intrinsics > & intrinsics) + const std::set< realdds::video_intrinsics > & intrinsics ) { rs2_video_stream prof; prof.type = stream_type; @@ -783,11 +783,13 @@ namespace librealsense prof.height = profile->height(); prof.fps = profile->frequency(); prof.fmt = static_cast< rs2_format >( profile->format().to_rs2() ); + prof.bpp = 0; - //Handle intrinsics - auto intr = std::find_if( intrinsics.begin(), intrinsics.end(), [profile]( const realdds::video_intrinsics & intr ) { - return profile->width() == intr.width && profile->height() == intr.height; - } ); + // Handle intrinsics + auto intr = std::find_if( intrinsics.begin(), + intrinsics.end(), + [profile]( const realdds::video_intrinsics & intr ) + { return profile->width() == intr.width && profile->height() == intr.height; } ); if( intr != intrinsics.end() ) //Some profiles don't have intrinsics { prof.intrinsics.width = intr->width; @@ -799,6 +801,10 @@ namespace librealsense prof.intrinsics.model = static_cast< rs2_distortion >( intr->distortion_model ); memcpy( prof.intrinsics.coeffs, intr->distortion_coeffs.data(), sizeof( prof.intrinsics.coeffs ) ); } + else + { + memset( &prof.intrinsics, 0, sizeof( prof.intrinsics ) ); + } return prof; } @@ -839,13 +845,12 @@ namespace librealsense , _dds_dev( dev ) { LOG_DEBUG( "=====> dds-device-proxy " << this << " created on top of dds-device " << _dds_dev.get() ); - auto & dev_info = dev->device_info(); - register_info( RS2_CAMERA_INFO_NAME, dev_info.name ); - register_info( RS2_CAMERA_INFO_SERIAL_NUMBER, dev_info.serial ); - register_info( RS2_CAMERA_INFO_PRODUCT_LINE, dev_info.product_line ); - register_info( RS2_CAMERA_INFO_PRODUCT_ID, dev_info.product_id ); - register_info( RS2_CAMERA_INFO_PHYSICAL_PORT, dev_info.topic_root ); - register_info( RS2_CAMERA_INFO_CAMERA_LOCKED, dev_info.locked ? "YES" : "NO" ); + register_info( RS2_CAMERA_INFO_NAME, dev->device_info().name ); + register_info( RS2_CAMERA_INFO_SERIAL_NUMBER, dev->device_info().serial ); + register_info( RS2_CAMERA_INFO_PRODUCT_LINE, dev->device_info().product_line ); + register_info( RS2_CAMERA_INFO_PRODUCT_ID, dev->device_info().product_id ); + register_info( RS2_CAMERA_INFO_PHYSICAL_PORT, dev->device_info().topic_root ); + register_info( RS2_CAMERA_INFO_CAMERA_LOCKED, dev->device_info().locked ? "YES" : "NO" ); //Assumes dds_device initialization finished struct sensor_info From 69b3be4f7c0279ac7db0eb47e79234f5616e3336 Mon Sep 17 00:00:00 2001 From: Eran Date: Mon, 27 Feb 2023 08:33:32 +0200 Subject: [PATCH 3/4] update cppcheck_run.log --- .github/workflows/cppcheck_run.log | 90 ++++++++--------------- .github/workflows/cppcheck_run.parsed.log | 7 -- 2 files changed, 31 insertions(+), 66 deletions(-) diff --git a/.github/workflows/cppcheck_run.log b/.github/workflows/cppcheck_run.log index d23fd78c7a..f01f00021e 100644 --- a/.github/workflows/cppcheck_run.log +++ b/.github/workflows/cppcheck_run.log @@ -41,6 +41,10 @@ + + + + @@ -59,10 +63,6 @@ - - - - @@ -78,9 +78,6 @@ - - - @@ -97,6 +94,9 @@ + + + @@ -150,30 +150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -190,10 +166,6 @@ - - - - @@ -213,21 +185,6 @@ - - - - - - - - - - - - - - - @@ -270,6 +227,21 @@ + + + + + + + + + + + + + + + @@ -307,13 +279,13 @@ - - - + + + @@ -379,18 +351,18 @@ - - - - - - + + + + + + diff --git a/.github/workflows/cppcheck_run.parsed.log b/.github/workflows/cppcheck_run.parsed.log index fa4c7fee1f..e69de29bb2 100644 --- a/.github/workflows/cppcheck_run.parsed.log +++ b/.github/workflows/cppcheck_run.parsed.log @@ -1,7 +0,0 @@ -E uninitvar src/context.cpp+803 Uninitialized variables: prof.bpp, prof.intrinsics -E danglingTempReference src/context.cpp+843 Using reference to dangling temporary. -E danglingTempReference src/context.cpp+844 Using reference to dangling temporary. -E danglingTempReference src/context.cpp+845 Using reference to dangling temporary. -E danglingTempReference src/context.cpp+846 Using reference to dangling temporary. -E danglingTempReference src/context.cpp+847 Using reference to dangling temporary. -E danglingTempReference src/context.cpp+848 Using reference to dangling temporary. From da074af2d0f07bbb2746bb77a3c334b98cae0142 Mon Sep 17 00:00:00 2001 From: Eran Date: Mon, 27 Feb 2023 08:44:26 +0200 Subject: [PATCH 4/4] fix CRLF --- .../include/realdds/dds-log-consumer.h | 96 +++++----- .../include/realdds/dds-topic-reader.h | 180 +++++++++--------- .../include/realdds/dds-topic-writer.h | 168 ++++++++-------- third-party/realdds/src/dds-stream-impl.h | 56 +++--- 4 files changed, 250 insertions(+), 250 deletions(-) diff --git a/third-party/realdds/include/realdds/dds-log-consumer.h b/third-party/realdds/include/realdds/dds-log-consumer.h index a1239f0aea..54db62567d 100644 --- a/third-party/realdds/include/realdds/dds-log-consumer.h +++ b/third-party/realdds/include/realdds/dds-log-consumer.h @@ -1,48 +1,48 @@ -// License: Apache 2.0. See LICENSE file in root directory. -// Copyright(c) 2022 Intel Corporation. All Rights Reserved. - -#pragma once - - -#include -#include - - -namespace realdds { - - -// Convert FastDDS Log::Entry to EasyLogging log (see ELPP_WRITE_LOG) -#define LOG_DDS_ENTRY( ENTRY, LEVEL, ... ) \ - do \ - { \ - char const * filename = ( ENTRY ).context.filename; \ - char const * func = ( ENTRY ).context.function; \ - if( ! func ) \ - func = "n/a"; \ - if( ! filename ) \ - filename = func; \ - el::base::Writer writer( el::Level::LEVEL, filename, ( ENTRY ).context.line, func ); \ - writer.construct( 1, "librealsense" ); \ - writer << __VA_ARGS__; \ - writer << " [DDS]"; \ - if( ( ENTRY ).context.category ) \ - writer << "[" << ( ENTRY ).context.category << "]"; \ - } \ - while( false ) - - -struct log_consumer : eprosima::fastdds::dds::LogConsumer -{ - static std::unique_ptr< eprosima::fastdds::dds::LogConsumer > create() - { - return std::unique_ptr< eprosima::fastdds::dds::LogConsumer >( new log_consumer ); - } - - void Consume( const eprosima::fastdds::dds::Log::Entry & e ) override; - -private: - log_consumer() = default; -}; - - -} // namespace realdds +// License: Apache 2.0. See LICENSE file in root directory. +// Copyright(c) 2022 Intel Corporation. All Rights Reserved. + +#pragma once + + +#include +#include + + +namespace realdds { + + +// Convert FastDDS Log::Entry to EasyLogging log (see ELPP_WRITE_LOG) +#define LOG_DDS_ENTRY( ENTRY, LEVEL, ... ) \ + do \ + { \ + char const * filename = ( ENTRY ).context.filename; \ + char const * func = ( ENTRY ).context.function; \ + if( ! func ) \ + func = "n/a"; \ + if( ! filename ) \ + filename = func; \ + el::base::Writer writer( el::Level::LEVEL, filename, ( ENTRY ).context.line, func ); \ + writer.construct( 1, "librealsense" ); \ + writer << __VA_ARGS__; \ + writer << " [DDS]"; \ + if( ( ENTRY ).context.category ) \ + writer << "[" << ( ENTRY ).context.category << "]"; \ + } \ + while( false ) + + +struct log_consumer : eprosima::fastdds::dds::LogConsumer +{ + static std::unique_ptr< eprosima::fastdds::dds::LogConsumer > create() + { + return std::unique_ptr< eprosima::fastdds::dds::LogConsumer >( new log_consumer ); + } + + void Consume( const eprosima::fastdds::dds::Log::Entry & e ) override; + +private: + log_consumer() = default; +}; + + +} // namespace realdds diff --git a/third-party/realdds/include/realdds/dds-topic-reader.h b/third-party/realdds/include/realdds/dds-topic-reader.h index 312d866659..f60d7eeaa6 100644 --- a/third-party/realdds/include/realdds/dds-topic-reader.h +++ b/third-party/realdds/include/realdds/dds-topic-reader.h @@ -1,90 +1,90 @@ -// License: Apache 2.0. See LICENSE file in root directory. -// Copyright(c) 2022 Intel Corporation. All Rights Reserved. - -#pragma once - -#include -#include - -#include -#include - - -namespace eprosima { -namespace fastdds { -namespace dds { -class Subscriber; -} // namespace dds -} // namespace fastdds -} // namespace eprosima - - -namespace realdds { - - -class dds_topic; -class dds_subscriber; - -// The 'reader' is the entity used to subscribe to updated values of data in a topic. It is bound at creation to this -// topic. -// -// You may choose to create one via a 'subscriber' that manages the activities of several readers. -// on_data_available callback will be called when a sample is received. -// -class dds_topic_reader : public eprosima::fastdds::dds::DataReaderListener -{ - std::shared_ptr< dds_topic > const _topic; - std::shared_ptr < dds_subscriber > const _subscriber; - - eprosima::fastdds::dds::DataReader * _reader = nullptr; - -public: - dds_topic_reader( std::shared_ptr< dds_topic > const & topic ); - dds_topic_reader( std::shared_ptr< dds_topic > const & topic, std::shared_ptr< dds_subscriber > const & subscriber ); - ~dds_topic_reader(); - - eprosima::fastdds::dds::DataReader * get() const { return _reader; } - eprosima::fastdds::dds::DataReader * operator->() const { return get(); } - - bool is_running() const { return ( get() != nullptr ); } - - std::shared_ptr< dds_topic > const & topic() const { return _topic; } - - typedef std::function< void() > on_data_available_callback; - typedef std::function< void( eprosima::fastdds::dds::SubscriptionMatchedStatus const & ) > - on_subscription_matched_callback; - - void on_data_available( on_data_available_callback callback ) { _on_data_available = std::move( callback ); } - void on_subscription_matched( on_subscription_matched_callback callback ) - { - _on_subscription_matched = std::move( callback ); - } - - class qos : public eprosima::fastdds::dds::DataReaderQos - { - using super = eprosima::fastdds::dds::DataReaderQos; - - public: - qos( eprosima::fastdds::dds::ReliabilityQosPolicyKind reliability - = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS, // default - eprosima::fastdds::dds::DurabilityQosPolicyKind durability - = eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS ); // default is transient local - }; - - // The callbacks should be set before we actually create the underlying DDS objects, so the reader does not - void run( qos const & = qos() ); - - // DataReaderListener -protected: - void on_subscription_matched( eprosima::fastdds::dds::DataReader *, - eprosima::fastdds::dds::SubscriptionMatchedStatus const & info ) override; - - void on_data_available( eprosima::fastdds::dds::DataReader * ) override; - -private: - on_data_available_callback _on_data_available; - on_subscription_matched_callback _on_subscription_matched; -}; - - -} // namespace realdds +// License: Apache 2.0. See LICENSE file in root directory. +// Copyright(c) 2022 Intel Corporation. All Rights Reserved. + +#pragma once + +#include +#include + +#include +#include + + +namespace eprosima { +namespace fastdds { +namespace dds { +class Subscriber; +} // namespace dds +} // namespace fastdds +} // namespace eprosima + + +namespace realdds { + + +class dds_topic; +class dds_subscriber; + +// The 'reader' is the entity used to subscribe to updated values of data in a topic. It is bound at creation to this +// topic. +// +// You may choose to create one via a 'subscriber' that manages the activities of several readers. +// on_data_available callback will be called when a sample is received. +// +class dds_topic_reader : public eprosima::fastdds::dds::DataReaderListener +{ + std::shared_ptr< dds_topic > const _topic; + std::shared_ptr < dds_subscriber > const _subscriber; + + eprosima::fastdds::dds::DataReader * _reader = nullptr; + +public: + dds_topic_reader( std::shared_ptr< dds_topic > const & topic ); + dds_topic_reader( std::shared_ptr< dds_topic > const & topic, std::shared_ptr< dds_subscriber > const & subscriber ); + ~dds_topic_reader(); + + eprosima::fastdds::dds::DataReader * get() const { return _reader; } + eprosima::fastdds::dds::DataReader * operator->() const { return get(); } + + bool is_running() const { return ( get() != nullptr ); } + + std::shared_ptr< dds_topic > const & topic() const { return _topic; } + + typedef std::function< void() > on_data_available_callback; + typedef std::function< void( eprosima::fastdds::dds::SubscriptionMatchedStatus const & ) > + on_subscription_matched_callback; + + void on_data_available( on_data_available_callback callback ) { _on_data_available = std::move( callback ); } + void on_subscription_matched( on_subscription_matched_callback callback ) + { + _on_subscription_matched = std::move( callback ); + } + + class qos : public eprosima::fastdds::dds::DataReaderQos + { + using super = eprosima::fastdds::dds::DataReaderQos; + + public: + qos( eprosima::fastdds::dds::ReliabilityQosPolicyKind reliability + = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS, // default + eprosima::fastdds::dds::DurabilityQosPolicyKind durability + = eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS ); // default is transient local + }; + + // The callbacks should be set before we actually create the underlying DDS objects, so the reader does not + void run( qos const & = qos() ); + + // DataReaderListener +protected: + void on_subscription_matched( eprosima::fastdds::dds::DataReader *, + eprosima::fastdds::dds::SubscriptionMatchedStatus const & info ) override; + + void on_data_available( eprosima::fastdds::dds::DataReader * ) override; + +private: + on_data_available_callback _on_data_available; + on_subscription_matched_callback _on_subscription_matched; +}; + + +} // namespace realdds diff --git a/third-party/realdds/include/realdds/dds-topic-writer.h b/third-party/realdds/include/realdds/dds-topic-writer.h index eaf202bf78..9efe9d6982 100644 --- a/third-party/realdds/include/realdds/dds-topic-writer.h +++ b/third-party/realdds/include/realdds/dds-topic-writer.h @@ -1,84 +1,84 @@ -// License: Apache 2.0. See LICENSE file in root directory. -// Copyright(c) 2022 Intel Corporation. All Rights Reserved. - -#pragma once - -#include -#include - -#include - - -namespace eprosima { -namespace fastdds { -namespace dds { -class Publisher; -} // namespace dds -} // namespace fastdds -} // namespace eprosima - - -namespace realdds { - - -class dds_topic; -class dds_publisher; - - -// The 'writer' is used to write data to a topic, bound at creation time (and therefore bound to a specific type). -// -// You may choose to create one via a 'publisher' that manages the activities of several writers and determines when the -// data is actually sent. By default, data is sent as soon as the writer�s write() function is called. -// -class dds_topic_writer : public eprosima::fastdds::dds::DataWriterListener -{ - std::shared_ptr< dds_topic > const _topic; - std::shared_ptr< dds_publisher > const _publisher; - - eprosima::fastdds::dds::DataWriter * _writer = nullptr; - -public: - dds_topic_writer( std::shared_ptr< dds_topic > const & topic ); - dds_topic_writer( std::shared_ptr< dds_topic > const & topic, std::shared_ptr< dds_publisher > const & publisher ); - ~dds_topic_writer(); - - eprosima::fastdds::dds::DataWriter * get() const { return _writer; } - eprosima::fastdds::dds::DataWriter * operator->() const { return get(); } - - bool is_running() const { return ( get() != nullptr ); } - - std::shared_ptr< dds_topic > const & topic() const { return _topic; } - - typedef std::function< void( eprosima::fastdds::dds::PublicationMatchedStatus const & ) > - on_publication_matched_callback; - void on_publication_matched( on_publication_matched_callback callback ) - { - _on_publication_matched = std::move( callback ); - } - - class qos : public eprosima::fastdds::dds::DataWriterQos - { - using super = eprosima::fastdds::dds::DataWriterQos; - - public: - qos( eprosima::fastdds::dds::ReliabilityQosPolicyKind reliability - = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS, // default - eprosima::fastdds::dds::DurabilityQosPolicyKind durability - = eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS ); // default is transient local - }; - - // The callbacks should be set before we actually create the underlying DDS objects, so the writer does not - void run( qos const & = qos() ); - - // DataWriterListener -protected: - // Called when the Publisher is matched (or unmatched) against an endpoint - void on_publication_matched( eprosima::fastdds::dds::DataWriter * writer, - eprosima::fastdds::dds::PublicationMatchedStatus const & info ) override; - -private: - on_publication_matched_callback _on_publication_matched; -}; - - -} // namespace realdds +// License: Apache 2.0. See LICENSE file in root directory. +// Copyright(c) 2022 Intel Corporation. All Rights Reserved. + +#pragma once + +#include +#include + +#include + + +namespace eprosima { +namespace fastdds { +namespace dds { +class Publisher; +} // namespace dds +} // namespace fastdds +} // namespace eprosima + + +namespace realdds { + + +class dds_topic; +class dds_publisher; + + +// The 'writer' is used to write data to a topic, bound at creation time (and therefore bound to a specific type). +// +// You may choose to create one via a 'publisher' that manages the activities of several writers and determines when the +// data is actually sent. By default, data is sent as soon as the writer�s write() function is called. +// +class dds_topic_writer : public eprosima::fastdds::dds::DataWriterListener +{ + std::shared_ptr< dds_topic > const _topic; + std::shared_ptr< dds_publisher > const _publisher; + + eprosima::fastdds::dds::DataWriter * _writer = nullptr; + +public: + dds_topic_writer( std::shared_ptr< dds_topic > const & topic ); + dds_topic_writer( std::shared_ptr< dds_topic > const & topic, std::shared_ptr< dds_publisher > const & publisher ); + ~dds_topic_writer(); + + eprosima::fastdds::dds::DataWriter * get() const { return _writer; } + eprosima::fastdds::dds::DataWriter * operator->() const { return get(); } + + bool is_running() const { return ( get() != nullptr ); } + + std::shared_ptr< dds_topic > const & topic() const { return _topic; } + + typedef std::function< void( eprosima::fastdds::dds::PublicationMatchedStatus const & ) > + on_publication_matched_callback; + void on_publication_matched( on_publication_matched_callback callback ) + { + _on_publication_matched = std::move( callback ); + } + + class qos : public eprosima::fastdds::dds::DataWriterQos + { + using super = eprosima::fastdds::dds::DataWriterQos; + + public: + qos( eprosima::fastdds::dds::ReliabilityQosPolicyKind reliability + = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS, // default + eprosima::fastdds::dds::DurabilityQosPolicyKind durability + = eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS ); // default is transient local + }; + + // The callbacks should be set before we actually create the underlying DDS objects, so the writer does not + void run( qos const & = qos() ); + + // DataWriterListener +protected: + // Called when the Publisher is matched (or unmatched) against an endpoint + void on_publication_matched( eprosima::fastdds::dds::DataWriter * writer, + eprosima::fastdds::dds::PublicationMatchedStatus const & info ) override; + +private: + on_publication_matched_callback _on_publication_matched; +}; + + +} // namespace realdds diff --git a/third-party/realdds/src/dds-stream-impl.h b/third-party/realdds/src/dds-stream-impl.h index 824cde4d37..2d27394899 100644 --- a/third-party/realdds/src/dds-stream-impl.h +++ b/third-party/realdds/src/dds-stream-impl.h @@ -1,28 +1,28 @@ -// License: Apache 2.0. See LICENSE file in root directory. -// Copyright(c) 2022 Intel Corporation. All Rights Reserved. - -#pragma once - -#include - -namespace realdds { - - -class dds_video_stream::impl -{ -public: - impl() - { - } -}; - -class dds_motion_stream::impl -{ -public: - impl() - { - } -}; - - -} // namespace realdds +// License: Apache 2.0. See LICENSE file in root directory. +// Copyright(c) 2022 Intel Corporation. All Rights Reserved. + +#pragma once + +#include + +namespace realdds { + + +class dds_video_stream::impl +{ +public: + impl() + { + } +}; + +class dds_motion_stream::impl +{ +public: + impl() + { + } +}; + + +} // namespace realdds