Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FW logs extended format #12688

Merged
merged 16 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
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
7 changes: 6 additions & 1 deletion common/output-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ void output_model::thread_loop()
rsutils::string::from()
<< "Invalid Hardware Logger XML at '" << hwlogger_xml << "': " << ex.what()
<< "\nEither configure valid XML or remove it" );
continue; // Don't try to get log entries for this device
}
}

fwlogger.start_collecting();
auto message = fwlogger.create_message();
while (fwlogger.get_firmware_log(message))
{
Expand Down Expand Up @@ -83,8 +85,11 @@ void output_model::thread_loop()
ss << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(elem) << " ";
add_log(message.get_severity(), __FILE__, 0, ss.str());
}
if (!enable_firmware_logs && fwlogger.get_number_of_fw_logs() == 0)
if( ! enable_firmware_logs && fwlogger.get_number_of_fw_logs() == 0 )
{
fwlogger.stop_collecting();
break;
}
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion common/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2709,7 +2709,7 @@ namespace rs2
}

{
ImGui::Text("HWLoggerEvents.xml Path:");
ImGui::Text("FW logs XML file:");
ImGui::SameLine();
static char logpath[256];
memset(logpath, 0, 256);
Expand All @@ -2721,6 +2721,19 @@ namespace rs2
path_str = logpath;
temp_cfg.set(configurations::viewer::hwlogger_xml, path_str);
}

ImGui::SameLine();
if( ImGui::Button( "FW logs XML" ) )
{
auto ret = file_dialog_open(open_file, "XML file\0*.xml\0", NULL, NULL);
if( ret )
{
memset( logpath, 0, 256 );
memcpy( logpath, ret, std::min( 255, static_cast< int >( strlen( ret ) ) ) );
path_str = logpath;
temp_cfg.set( configurations::viewer::hwlogger_xml, path_str );
}
}
}

ImGui::Separator();
Expand Down
28 changes: 26 additions & 2 deletions include/librealsense2/h/rs_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,20 @@ void rs2_software_sensor_add_option(rs2_sensor* sensor, rs2_option option, float
void rs2_software_sensor_detach(rs2_sensor* sensor, rs2_error** error);


/**
* \brief Starts collecting FW log messages in the device.
* \param[in] dev Device that will start collecting log messages.
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are
*/
void rs2_start_collecting_fw_logs( rs2_device * dev, rs2_error ** error );

/**
* \brief Stops collecting FW log messages in the device.
* \param[in] dev Device that will stop collecting log messages.
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are
*/
void rs2_stop_collecting_fw_logs( rs2_device * dev, rs2_error ** error );

/**
* \brief Creates RealSense firmware log message.
* \param[in] dev Device from which the FW log will be taken using the created message
Expand Down Expand Up @@ -483,13 +497,23 @@ const char* rs2_get_fw_log_parsed_message(rs2_firmware_log_parsed_message* fw_lo
const char* rs2_get_fw_log_parsed_file_name(rs2_firmware_log_parsed_message* fw_log_parsed_msg, rs2_error** error);
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved

/**
* \brief Gets RealSense firmware log parsed message thread name.
* \brief Gets RealSense firmware log parsed message source (SoC) or thread name.
* \param[in] fw_log_parsed_msg firmware log parsed message object
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored.
* \return thread name of the firmware log parsed message
* \return source (SoC) or thread name of the firmware log parsed message
*/
const char* rs2_get_fw_log_parsed_thread_name(rs2_firmware_log_parsed_message* fw_log_parsed_msg, rs2_error** error);

/**
* \brief Gets RealSense firmware log parsed message module name.
* \param[in] fw_log_parsed_msg firmware log parsed message object
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are
* ignored. \return module name of the firmware log parsed message
*/
const char * rs2_get_fw_log_parsed_module_name( rs2_firmware_log_parsed_message * fw_log_parsed_msg,
rs2_error ** error );


/**
* \brief Gets RealSense firmware log parsed message severity.
* \param[in] fw_log_parsed_msg firmware log parsed message object
Expand Down
25 changes: 23 additions & 2 deletions include/librealsense2/hpp/rs_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,16 @@ namespace rs2
std::string thread_name() const
{
rs2_error* e = nullptr;
std::string thread_name(rs2_get_fw_log_parsed_thread_name(_parsed_fw_log.get(), &e));
std::string name(rs2_get_fw_log_parsed_thread_name(_parsed_fw_log.get(), &e));
error::handle(e);
return thread_name;
return name;
}
std::string module_name() const
{
rs2_error * e = nullptr;
std::string name( rs2_get_fw_log_parsed_module_name( _parsed_fw_log.get(), &e ) );
error::handle( e );
return name;
}
std::string severity() const
{
Expand Down Expand Up @@ -450,6 +457,20 @@ namespace rs2
error::handle(e);
}

void start_collecting()
{
rs2_error * e = nullptr;
rs2_start_collecting_fw_logs( _dev.get(), &e );
error::handle( e );
}

void stop_collecting()
{
rs2_error * e = nullptr;
rs2_start_collecting_fw_logs( _dev.get(), &e );
error::handle( e );
}

rs2::firmware_log_message create_message()
{
rs2_error* e = nullptr;
Expand Down
Loading
Loading