Skip to content

Commit

Permalink
fix DDS 'log' notification timestamp output
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Dec 27, 2023
1 parent 0de8510 commit 48ef97f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion third-party/realdds/include/realdds/dds-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class dds_device
rsutils::subscription on_metadata_available( on_metadata_available_callback && );

typedef std::function< void(
dds_time const & timestamp, char type, std::string const & text, nlohmann::json const & data ) >
dds_nsec timestamp, char type, std::string const & text, nlohmann::json const & data ) >
on_device_log_callback;
rsutils::subscription on_device_log( on_device_log_callback && cb );

Expand Down
4 changes: 2 additions & 2 deletions third-party/realdds/py/pyrealdds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,10 +898,10 @@ PYBIND11_MODULE(NAME, m) {
{ FN_FWD_CALL( dds_device, "on_metadata_available", callback( self, json_to_py( *pj ) ); ) } ) );
} )
.def( "on_device_log",
[]( dds_device & self, std::function< void( dds_device &, dds_time const &, char, std::string const &, py::object && ) > callback )
[]( dds_device & self, std::function< void( dds_device &, dds_nsec, char, std::string const &, py::object && ) > callback )
{
return std::make_shared< subscription >( self.on_device_log(
[&self, callback]( dds_time const & timestamp, char type, std::string const & text, nlohmann::json const & data )
[&self, callback]( dds_nsec timestamp, char type, std::string const & text, nlohmann::json const & data )
{ FN_FWD_CALL( dds_device, "on_device_log", callback( self, timestamp, type, text, json_to_py( data ) ); ) } ) );
} )
.def( "on_notification",
Expand Down
4 changes: 2 additions & 2 deletions third-party/realdds/src/dds-device-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ void dds_device::impl::on_log( nlohmann::json const & j, eprosima::fastdds::dds:
throw std::runtime_error( "not an array" );
if( entry.size() < 3 || entry.size() > 4 )
throw std::runtime_error( "bad array length" );
auto timestamp = time_from( rsutils::json::get< dds_nsec >( entry, 0 ) );
auto timestamp = rsutils::json::get< dds_nsec >( entry, 0 );
auto const & stype = rsutils::json::string_ref( entry[1] );
if( stype.length() != 1 || ! strchr( "EWID", stype[0] ) )
throw std::runtime_error( "type not one of 'EWID'" );
Expand All @@ -365,7 +365,7 @@ void dds_device::impl::on_log( nlohmann::json const & j, eprosima::fastdds::dds:
nlohmann::json const & data = entry.size() > 3 ? entry[3] : rsutils::json::null_json;

if( ! _on_device_log.raise( timestamp, type, text, data ) )
LOG_DEBUG( "[" << debug_name() << "][" << timestr( timestamp ) << "][" << type << "] " << text
LOG_DEBUG( "[" << debug_name() << "][" << timestamp << "][" << type << "] " << text
<< " [" << data << "]" );
}
catch( std::exception const & e )
Expand Down
2 changes: 1 addition & 1 deletion third-party/realdds/src/dds-device-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class dds_device::impl
return _on_metadata_available.subscribe( std::move( cb ) );
}

using on_device_log_signal = rsutils::signal< dds_time const &, // timestamp
using on_device_log_signal = rsutils::signal< dds_nsec, // timestamp
char, // type
std::string const &, // text
nlohmann::json const & >; // data
Expand Down

0 comments on commit 48ef97f

Please sign in to comment.