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 authored and bkueng committed Aug 6, 2019
1 parent f21dc82 commit cd85f58
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/drivers/camera_trigger/camera_trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class CameraTrigger : public px4::ScheduledWorkItem
/**
* Start the task.
*/
void start();
bool start();

/**
* Stop the task.
Expand Down Expand Up @@ -427,9 +427,17 @@ CameraTrigger::shoot_once()
}
}

void
bool
CameraTrigger::start()
{
if (_camera_interface == nullptr) {
if (camera_trigger::g_camera_trigger != nullptr) {
delete (camera_trigger::g_camera_trigger);
}

return false;
}

if ((_trigger_mode == TRIGGER_MODE_INTERVAL_ALWAYS_ON ||
_trigger_mode == TRIGGER_MODE_DISTANCE_ALWAYS_ON) &&
_camera_interface->has_power_control() &&
Expand All @@ -456,6 +464,8 @@ CameraTrigger::start()

// start to monitor at high rate for trigger enable command
ScheduleNow();

return true;
}

void
Expand Down Expand Up @@ -827,7 +837,11 @@ int camera_trigger_main(int argc, char *argv[])
return 1;
}

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

return 0;
}

Expand Down

0 comments on commit cd85f58

Please sign in to comment.