Browse Source

AP_BattMonitor: removed create() method for objects

See discussion here:

  https://github.com/ArduPilot/ardupilot/issues/7331

we were getting some uninitialised variables. While it only showed up in
AP_SbusOut, it means we can't be sure it won't happen on other objects,
so safest to remove the approach

Thanks to assistance from Lucas, Peter and Francisco
master
Andrew Tridgell 7 years ago
parent
commit
a4c56fcb82
  1. 6
      libraries/AP_BattMonitor/AP_BattMonitor.h
  2. 2
      libraries/AP_BattMonitor/examples/AP_BattMonitor_test/AP_BattMonitor_test.cpp

6
libraries/AP_BattMonitor/AP_BattMonitor.h

@ -37,9 +37,7 @@ class AP_BattMonitor @@ -37,9 +37,7 @@ class AP_BattMonitor
friend class AP_BattMonitor_SMBus_Maxell;
public:
static AP_BattMonitor create() { return AP_BattMonitor{}; }
constexpr AP_BattMonitor(AP_BattMonitor &&other) = default;
AP_BattMonitor();
/* Do not allow copies */
AP_BattMonitor(const AP_BattMonitor &other) = delete;
@ -179,8 +177,6 @@ protected: @@ -179,8 +177,6 @@ protected:
AP_Int8 _low_voltage_source; /// voltage type used for detection of low voltage event
private:
AP_BattMonitor();
BattMonitor_State state[AP_BATT_MONITOR_MAX_INSTANCES];
AP_BattMonitor_Backend *drivers[AP_BATT_MONITOR_MAX_INSTANCES];
uint8_t _num_instances; /// number of monitors

2
libraries/AP_BattMonitor/examples/AP_BattMonitor_test/AP_BattMonitor_test.cpp

@ -11,7 +11,7 @@ void loop(); @@ -11,7 +11,7 @@ void loop();
const AP_HAL::HAL& hal = AP_HAL::get_HAL();
static AP_BattMonitor battery_mon = AP_BattMonitor::create();
static AP_BattMonitor battery_mon;
uint32_t timer;
void setup() {

Loading…
Cancel
Save