From baf41ae92eccdc2b8893513ad639a632be08fc09 Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Thu, 15 Aug 2024 18:19:24 +0100 Subject: [PATCH] AP_Volz_Protocol: rate limit logs to 5Hz --- libraries/AP_Volz_Protocol/AP_Volz_Protocol.cpp | 10 ++++++---- libraries/AP_Volz_Protocol/AP_Volz_Protocol.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/AP_Volz_Protocol/AP_Volz_Protocol.cpp b/libraries/AP_Volz_Protocol/AP_Volz_Protocol.cpp index 3c34a4f519..43f1c17feb 100644 --- a/libraries/AP_Volz_Protocol/AP_Volz_Protocol.cpp +++ b/libraries/AP_Volz_Protocol/AP_Volz_Protocol.cpp @@ -376,11 +376,13 @@ void AP_Volz_Protocol::update() servo_pwm[i] = (pwm == 0) ? c->get_trim() : pwm; } - // take semaphore and log all channels #if HAL_LOGGING_ENABLED - { + // take semaphore and log all channels at 5 Hz + const uint32_t now_ms = AP_HAL::millis(); + if ((now_ms - telem.last_log_ms) > 200) { + telem.last_log_ms = now_ms; + WITH_SEMAPHORE(telem.sem); - const uint32_t now_ms = AP_HAL::millis(); for (uint8_t i=0; i 5000)) { // Never seen telem, or not had a response for more than 5 seconds @@ -417,7 +419,7 @@ void AP_Volz_Protocol::update() ); } } -#endif +#endif // HAL_LOGGING_ENABLED } // Return the crc for a given command packet diff --git a/libraries/AP_Volz_Protocol/AP_Volz_Protocol.h b/libraries/AP_Volz_Protocol/AP_Volz_Protocol.h index 417cf01486..02b18fc4ea 100644 --- a/libraries/AP_Volz_Protocol/AP_Volz_Protocol.h +++ b/libraries/AP_Volz_Protocol/AP_Volz_Protocol.h @@ -143,6 +143,7 @@ private: uint16_t motor_temp_deg; uint16_t pcb_temp_deg; } data[NUM_SERVO_CHANNELS]; + uint32_t last_log_ms; } telem; #endif