AP_OpticalFlow: auto-start px4flow driver if enabled

This commit is contained in:
Andrew Tridgell 2016-08-03 14:45:21 +10:00
parent 74182b6b3d
commit 78b2924c00
1 changed files with 11 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
#include <AP_BoardConfig/AP_BoardConfig.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -39,8 +40,18 @@ OpticalFlow_backend(_frontend)
{}
extern "C" int px4flow_main(int, char **);
void AP_OpticalFlow_PX4::init(void)
{
#if defined(CONFIG_ARCH_BOARD_PX4FMU_V1) || defined(CONFIG_ARCH_BOARD_PX4FMU_V2)
if (!AP_BoardConfig::px4_start_driver(px4flow_main, "px4flow", "start")) {
hal.console->printf("Unable to start px4flow driver\n");
} else {
// give it time to initialise
hal.scheduler->delay(500);
}
#endif
_fd = open(PX4FLOW0_DEVICE_PATH, O_RDONLY);
// check for failure to open device