Skip to content

Commit

Permalink
PR #12835 from OhadMeir: Update fw_logs in Python wrapper + few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir authored Apr 7, 2024
2 parents 3053e9f + 55c228f commit d3eeb2c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/librealsense2/hpp/rs_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ namespace rs2
void stop_collecting()
{
rs2_error * e = nullptr;
rs2_start_collecting_fw_logs( _dev.get(), &e );
rs2_stop_collecting_fw_logs( _dev.get(), &e );
error::handle( e );
}

Expand Down
4 changes: 2 additions & 2 deletions src/fw-logs/fw-logs-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace librealsense
{
if( source.first >= fw_logs::max_sources )
throw librealsense::invalid_value_exception( rsutils::string::from() << "Supporting source id 0 to "
<< fw_logs::max_sources << ". Found source ("
<< fw_logs::max_sources - 1 << ". Found source ("
<< source.first << ", " << source.second << ")" );

initialize_source_formatting_options( source, definitions_xml );
Expand Down Expand Up @@ -193,7 +193,7 @@ namespace librealsense
auto verbosity = fw_logs_xml_helper::get_source_module_verbosity( source.first, definitions_xml );
if( ! verbosity.empty() && verbosity.rbegin()->first >= fw_logs::max_modules )
throw librealsense::invalid_value_exception( rsutils::string::from() << "Supporting module id 0 to "
<< fw_logs::max_modules << ". Found module "
<< fw_logs::max_modules - 1 << ". Found module "
<< verbosity.rbegin()->first << " in source ("
<< source.first << ", " << source.second << ")" );

Expand Down
4 changes: 3 additions & 1 deletion src/fw-logs/fw-logs-xml-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void load_external_xml( xml_document<> * document, std::vector< char > & buffer
xml_node<> * get_first_node( const xml_document<> * document )
{
xml_node<> * root = document->first_node();
if( !root )
throw librealsense::invalid_value_exception( "Cannot find XML root" );

std::string root_name( root->name(), root->name() + root->name_size() );
if( root_name.compare( "Format" ) != 0 )
Expand Down Expand Up @@ -150,7 +152,7 @@ std::string fw_logs_xml_helper::get_source_parser_file_path( int source_id, cons
std::string path = get_file_path( source_node );
if( path.empty() )
throw librealsense::invalid_value_exception( rsutils::string::from()
<< "Did not find 'File' attribute for source " << source_id );
<< "Did not find File 'Path' attribute for source " << source_id );

return path;
}
Expand Down
6 changes: 4 additions & 2 deletions wrappers/python/pyrs_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ void init_internal(py::module &m) {
firmware_log_parsed_message.def("get_message", &rs2::firmware_log_parsed_message::message, "Get message ")
.def("get_file_name", &rs2::firmware_log_parsed_message::file_name, "Get file name ")
.def("get_thread_name", &rs2::firmware_log_parsed_message::thread_name, "Get thread name ")
.def("get_module_name", &rs2::firmware_log_parsed_message::module_name, "Get module name ")
.def("get_severity", &rs2::firmware_log_parsed_message::severity, "Get severity ")
.def("get_line", &rs2::firmware_log_parsed_message::line, "Get line ")
.def("get_timestamp", &rs2::firmware_log_parsed_message::timestamp, "Get timestamp ")
Expand All @@ -240,11 +241,12 @@ void init_internal(py::module &m) {
firmware_logger.def(py::init<rs2::device>(), "device"_a)
.def("create_message", &rs2::firmware_logger::create_message, "Create FW Log")
.def("create_parsed_message", &rs2::firmware_logger::create_parsed_message, "Create FW Parsed Log")
.def("start_collecting", &rs2::firmware_logger::start_collecting, "Start collecting FW logs")
.def("stop_collecting", &rs2::firmware_logger::stop_collecting, "Stop collecting FW logs")
.def("get_number_of_fw_logs", &rs2::firmware_logger::get_number_of_fw_logs, "Get Number of Fw Logs Polled From Device")
.def("get_firmware_log", &rs2::firmware_logger::get_firmware_log, "Get FW Log", "msg"_a)
.def("get_flash_log", &rs2::firmware_logger::get_flash_log, "Get Flash Log", "msg"_a)
.def("init_parser", &rs2::firmware_logger::init_parser, "Initialize Parser with content of xml file",
"xml_content"_a)
.def("init_parser", &rs2::firmware_logger::init_parser, "Initialize Parser with content of xml file", "xml_content"_a)
.def("parse_log", &rs2::firmware_logger::parse_log, "Parse Fw Log ", "msg"_a, "parsed_msg"_a);

// rs2::terminal_parser
Expand Down

0 comments on commit d3eeb2c

Please sign in to comment.