Browse Source

AP_OpticalFlow: auto-start px4flow driver if enabled

master
Andrew Tridgell 9 years ago
parent
commit
78b2924c00
  1. 11
      libraries/AP_OpticalFlow/AP_OpticalFlow_PX4.cpp

11
libraries/AP_OpticalFlow/AP_OpticalFlow_PX4.cpp

@ -24,6 +24,7 @@ @@ -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) @@ -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

Loading…
Cancel
Save