AP_BattMonitor: fixed SITL segfault

This commit is contained in:
Andrew Tridgell 2017-11-04 19:41:41 +11:00
parent 274e441292
commit c9652fec3c
1 changed files with 3 additions and 1 deletions

View File

@ -18,7 +18,9 @@ AP_BattMonitor_SMBus::AP_BattMonitor_SMBus(AP_BattMonitor &mon,
}
void AP_BattMonitor_SMBus::init(void) {
_dev->register_periodic_callback(100000, FUNCTOR_BIND_MEMBER(&AP_BattMonitor_SMBus::timer, void));
if (_dev) {
_dev->register_periodic_callback(100000, FUNCTOR_BIND_MEMBER(&AP_BattMonitor_SMBus::timer, void));
}
}
/// read the battery_voltage and current, should be called at 10hz