From 2e6063495f32536a84f2ce9981451e268b5fb892 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 28 Dec 2021 19:08:34 +1100 Subject: [PATCH] AP_BattMonitor: fixed a segv with BATT_MONITOR=14 this causes a hang on boot on some boards --- libraries/AP_BattMonitor/AP_BattMonitor_SMBus_SUI.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_SUI.cpp b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_SUI.cpp index e975523bcf..d58e229856 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_SUI.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_SUI.cpp @@ -23,12 +23,14 @@ AP_BattMonitor_SMBus_SUI::AP_BattMonitor_SMBus_SUI(AP_BattMonitor &mon, cell_count(_cell_count) { _pec_supported = false; - _dev->set_retries(2); } void AP_BattMonitor_SMBus_SUI::init(void) { AP_BattMonitor_SMBus::init(); + if (_dev) { + _dev->set_retries(2); + } if (_dev && timer_handle) { // run twice as fast for two phases _dev->adjust_periodic_callback(timer_handle, 50000);