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

AP_TemperatureSensor: add logging option to only log sensors with no source #27675

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 7 additions & 3 deletions libraries/AP_TemperatureSensor/AP_TemperatureSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ const AP_Param::GroupInfo AP_TemperatureSensor::var_info[] = {

// SKIP INDEX 0

#if HAL_LOGGING_ENABLED
// @Param: _LOG
// @DisplayName: Logging
// @Description: Enables temperature sensor logging
// @Values: 0:Disabled, 1:Enabled
// @Values: 0:Disabled, 1:Log all instances, 2: Log only instances with sensor source set to None
// @User: Standard
AP_GROUPINFO("_LOG", 1, AP_TemperatureSensor, _log_flag, 0),
AP_GROUPINFO("_LOG", 1, AP_TemperatureSensor, _logging_type, 0),
#endif

// SKIP Index 2-9 to be for parameters that apply to every sensor

Expand Down Expand Up @@ -239,7 +241,9 @@ void AP_TemperatureSensor::update()

#if HAL_LOGGING_ENABLED
const AP_Logger *logger = AP_Logger::get_singleton();
if (logger != nullptr && _log_flag) {
const bool should_log = (_logging_type == LoggingType::All) ||
((_logging_type == LoggingType::SourceNone) && (_params[i].source == AP_TemperatureSensor_Params::Source::None));
if (logger != nullptr && should_log) {
drivers[i]->Log_Write_TEMP();
}
#endif
Expand Down
10 changes: 8 additions & 2 deletions libraries/AP_TemperatureSensor/AP_TemperatureSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ class AP_TemperatureSensor

uint8_t _num_instances; // number of temperature sensors

// Parameters
AP_Int8 _log_flag; // log_flag: true if we should log all sensors data
#if HAL_LOGGING_ENABLED
enum class LoggingType : uint8_t {
All = 1,
SourceNone = 2,
};
AP_Enum<LoggingType> _logging_type;
#endif

};

namespace AP {
Expand Down
Loading