Skip to content

Commit

Permalink
camera trigger: do not try to start if interface was not created
Browse files Browse the repository at this point in the history
Signed-off-by: RomanBapst <bapstroman@gmail.com>
  • Loading branch information
RomanBapst committed Jul 24, 2019
1 parent 2fbb70d commit 4d14a00
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/drivers/camera_trigger/camera_trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class CameraTrigger
/**
* Start the task.
*/
void start();
bool start();

/**
* Stop the task.
Expand Down Expand Up @@ -442,9 +442,12 @@ CameraTrigger::shoot_once()

}

void
bool
CameraTrigger::start()
{
if (_camera_interface == nullptr) {
return false;
}

if ((_trigger_mode == TRIGGER_MODE_INTERVAL_ALWAYS_ON ||
_trigger_mode == TRIGGER_MODE_DISTANCE_ALWAYS_ON) &&
Expand Down Expand Up @@ -473,6 +476,8 @@ CameraTrigger::start()
// start to monitor at high rate for trigger enable command
work_queue(LPWORK, &_work, (worker_t)&CameraTrigger::cycle_trampoline, this, USEC2TICK(1));

return true;

}

void
Expand Down Expand Up @@ -876,7 +881,12 @@ int camera_trigger_main(int argc, char *argv[])
return 1;
}

camera_trigger::g_camera_trigger->start();
if (!camera_trigger::g_camera_trigger->start()) {
camera_trigger::g_camera_trigger->stop();
PX4_WARN("failed to start camera trigger");
return 1;
}

return 0;
}

Expand Down

0 comments on commit 4d14a00

Please sign in to comment.