diff --git a/.ci/Jenkinsfile-hardware b/.ci/Jenkinsfile-hardware index f77796764d..c281d7b011 100644 --- a/.ci/Jenkinsfile-hardware +++ b/.ci/Jenkinsfile-hardware @@ -694,9 +694,9 @@ void statusFTDI() { sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "dmesg"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "fmu status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "free"' - sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "logger status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "listener adc_report"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "listener battery_status"' + sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "listener logger_status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "listener sensor_accel"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "listener sensor_accel_fifo"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "listener sensor_accel_integrated"' @@ -709,13 +709,14 @@ void statusFTDI() { sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "listener sensor_mag"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "listener servorail_status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "listener system_power"' + sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "logger status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "ls /"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "ls /dev"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "ls /etc"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "ls /obj"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "ls /proc"' - sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "mavlink status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "mavlink status streams"' + sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "mavlink status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "mtd status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "param show"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "param status"' @@ -743,9 +744,9 @@ void statusSEGGER() { sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "dmesg"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "fmu status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "free"' - sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "logger status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "listener adc_report"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "listener battery_status"' + sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "listener logger_status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "listener sensor_accel"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "listener sensor_accel_fifo"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "listener sensor_accel_integrated"' @@ -758,13 +759,14 @@ void statusSEGGER() { sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "listener sensor_mag"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "listener servorail_status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "listener system_power"' + sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "logger status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "ls /"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "ls /dev"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "ls /etc"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "ls /obj"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "ls /proc"' - sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "mavlink status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "mavlink status streams"' + sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "mavlink status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "mtd status"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "param show"' sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "param status"' diff --git a/msg/CMakeLists.txt b/msg/CMakeLists.txt index e92eff278c..c32f6d8346 100644 --- a/msg/CMakeLists.txt +++ b/msg/CMakeLists.txt @@ -76,6 +76,7 @@ set(msg_files landing_target_pose.msg led_control.msg log_message.msg + logger_status.msg manual_control_setpoint.msg mavlink_log.msg mission.msg diff --git a/msg/logger_status.msg b/msg/logger_status.msg new file mode 100644 index 0000000000..52721244ed --- /dev/null +++ b/msg/logger_status.msg @@ -0,0 +1,20 @@ +uint64 timestamp # time since system start (microseconds) + +uint8 LOGGER_TYPE_FULL = 0 # Normal, full size log +uint8 LOGGER_TYPE_MISSION = 1 # reduced mission log (e.g. for geotagging) +uint8 type + +uint8 BACKEND_FILE = 1 +uint8 BACKEND_MAVLINK = 2 +uint8 BACKEND_ALL = 3 +uint8 backend + +float32 total_written_kb # total written to log in kiloBytes +float32 write_rate_kb_s # write rate in kiloBytes/s + +uint32 dropouts # number of failed buffer writes due to buffer overflow + +uint32 buffer_used_bytes # current buffer fill in Bytes +uint32 buffer_size_bytes # total buffer size in Bytes + +uint8 num_messages diff --git a/msg/tools/uorb_rtps_message_ids.yaml b/msg/tools/uorb_rtps_message_ids.yaml index 69cea00748..55c953fe57 100644 --- a/msg/tools/uorb_rtps_message_ids.yaml +++ b/msg/tools/uorb_rtps_message_ids.yaml @@ -279,6 +279,8 @@ rtps: id: 124 - msg: vehicle_angular_acceleration id: 125 + - msg: logger_status + id: 126 ########## multi topics: begin ########## - msg: actuator_controls_0 id: 150 diff --git a/src/modules/logger/logged_topics.cpp b/src/modules/logger/logged_topics.cpp index 9ff9525321..ac18e1890a 100644 --- a/src/modules/logger/logged_topics.cpp +++ b/src/modules/logger/logged_topics.cpp @@ -96,6 +96,7 @@ void LoggedTopics::add_default_topics() // multi topics add_topic_multi("actuator_outputs", 100); + add_topic_multi("logger_status"); add_topic_multi("multirotor_motor_limits", 1000); add_topic_multi("telemetry_status", 1000); add_topic_multi("wind_estimate", 1000); diff --git a/src/modules/logger/logger.cpp b/src/modules/logger/logger.cpp index 599b0bffdc..42a1cab7d4 100644 --- a/src/modules/logger/logger.cpp +++ b/src/modules/logger/logger.cpp @@ -785,11 +785,34 @@ void Logger::run() _last_sync_time = loop_time; } - // update buffer statistics - for (int i = 0; i < (int)LogType::Count; ++i) { - if (!_statistics[i].dropout_start && (_writer.get_buffer_fill_count_file((LogType)i) > _statistics[i].high_water)) { - _statistics[i].high_water = _writer.get_buffer_fill_count_file((LogType)i); + // publish logger status + if (hrt_elapsed_time(&_logger_status_last) >= 1_s) { + for (int i = 0; i < (int)LogType::Count; ++i) { + + const LogType log_type = static_cast(i); + + if (_writer.is_started(log_type)) { + + const size_t buffer_fill_count_file = _writer.get_buffer_fill_count_file(log_type); + + const float kb_written = _writer.get_total_written_file(log_type) / 1024.0f; + const float seconds = hrt_elapsed_time(&_statistics[i].start_time_file) * 1e-6f; + + logger_status_s status; + status.type = i; + status.backend = _writer.backend(); + status.total_written_kb = kb_written; + status.write_rate_kb_s = kb_written / seconds; + status.dropouts = _statistics[i].write_dropouts; + status.buffer_used_bytes = buffer_fill_count_file; + status.buffer_size_bytes = _writer.get_buffer_size_file(log_type); + status.num_messages = _num_subscriptions; + status.timestamp = hrt_absolute_time(); + _logger_status_pub[i].publish(status); + } } + + _logger_status_last = hrt_absolute_time(); } /* release the log buffer */ diff --git a/src/modules/logger/logger.h b/src/modules/logger/logger.h index ac4f093679..d1d8683ae2 100644 --- a/src/modules/logger/logger.h +++ b/src/modules/logger/logger.h @@ -44,8 +44,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -335,6 +337,9 @@ private: hrt_abstime _next_load_print{0}; ///< timestamp when to print the process load PrintLoadReason _print_load_reason {PrintLoadReason::Preflight}; + uORB::PublicationMulti _logger_status_pub[2] { ORB_ID(logger_status), ORB_ID(logger_status) }; + hrt_abstime _logger_status_last{0}; + uORB::Subscription _manual_control_sp_sub{ORB_ID(manual_control_setpoint)}; uORB::Subscription _vehicle_command_sub{ORB_ID(vehicle_command)}; uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};