camera trigger: do not try to start if interface was not created

Signed-off-by: RomanBapst <bapstroman@gmail.com>
This commit is contained in:
RomanBapst
2019-07-24 10:56:47 +02:00
committed by Beat Küng
parent f21dc82c24
commit cd85f584cf
+17 -3
View File
@@ -133,7 +133,7 @@ public:
/**
* Start the task.
*/
void start();
bool start();
/**
* Stop the task.
@@ -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() &&
@@ -456,6 +464,8 @@ CameraTrigger::start()
// start to monitor at high rate for trigger enable command
ScheduleNow();
return true;
}
void
@@ -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;
}