diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_PX4.cpp b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_PX4.cpp index bccefe66fd..7a186c32d1 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_PX4.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_PX4.cpp @@ -21,6 +21,7 @@ #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 +#include #include "AP_BattMonitor_SMBus_PX4.h" #include @@ -33,6 +34,8 @@ extern const AP_HAL::HAL& hal; +extern "C" int batt_smbus_main(int, char **); + // Constructor AP_BattMonitor_SMBus_PX4::AP_BattMonitor_SMBus_PX4(AP_BattMonitor &mon, uint8_t instance, AP_BattMonitor::BattMonitor_State &mon_state) : AP_BattMonitor_SMBus(mon, instance, mon_state), @@ -45,6 +48,12 @@ AP_BattMonitor_SMBus_PX4::AP_BattMonitor_SMBus_PX4(AP_BattMonitor &mon, uint8_t void AP_BattMonitor_SMBus_PX4::init() { + if (!AP_BoardConfig::px4_start_driver(batt_smbus_main, "batt_smbus", "-b 2 start")) { + hal.console->printf("Unable to start batt_smbus driver\n"); + } else { + // give it time to initialise + hal.scheduler->delay(500); + } // open the device _batt_fd = open(BATT_SMBUS0_DEVICE_PATH, O_RDWR); if (_batt_fd == -1) {