aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Oes <julian@oes.ch>2013-11-05 19:56:33 +0100
committerJulian Oes <julian@oes.ch>2013-11-05 19:56:33 +0100
commit4502c285eb8b284b7c08666b6d0e3e81035bace3 (patch)
tree717f85b09691bbde7eba6b209d39429899696b0e
parent857c3d2efd49085dfd28827b06d96776340e5a09 (diff)
downloadpx4-firmware-4502c285eb8b284b7c08666b6d0e3e81035bace3.tar.gz
px4-firmware-4502c285eb8b284b7c08666b6d0e3e81035bace3.tar.bz2
px4-firmware-4502c285eb8b284b7c08666b6d0e3e81035bace3.zip
Startup scripts: Start the commander early and let it try to open the mavlink_fd with 20Hz
-rw-r--r--ROMFS/px4fmu_common/init.d/rc.fixedwing5
-rw-r--r--ROMFS/px4fmu_common/init.d/rc.multirotor5
-rwxr-xr-xROMFS/px4fmu_common/init.d/rcS5
-rw-r--r--src/modules/commander/commander.cpp17
4 files changed, 12 insertions, 20 deletions
diff --git a/ROMFS/px4fmu_common/init.d/rc.fixedwing b/ROMFS/px4fmu_common/init.d/rc.fixedwing
index 79e34a3b9..f02851006 100644
--- a/ROMFS/px4fmu_common/init.d/rc.fixedwing
+++ b/ROMFS/px4fmu_common/init.d/rc.fixedwing
@@ -4,11 +4,6 @@
#
#
-# Start the Commander
-#
-commander start
-
-#
# Start the sensors and test them.
#
sh /etc/init.d/rc.sensors
diff --git a/ROMFS/px4fmu_common/init.d/rc.multirotor b/ROMFS/px4fmu_common/init.d/rc.multirotor
index 6bae99175..bc550ac5a 100644
--- a/ROMFS/px4fmu_common/init.d/rc.multirotor
+++ b/ROMFS/px4fmu_common/init.d/rc.multirotor
@@ -4,11 +4,6 @@
#
#
-# Start the Commander
-#
-commander start
-
-#
# Start the sensors and test them.
#
sh /etc/init.d/rc.sensors
diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS
index cff8446a6..d8b5cb608 100755
--- a/ROMFS/px4fmu_common/init.d/rcS
+++ b/ROMFS/px4fmu_common/init.d/rcS
@@ -105,6 +105,11 @@ then
blinkm systemstate
fi
fi
+
+ #
+ # Start the Commander (needs to be this early for in-air-restarts)
+ #
+ commander start
if param compare SYS_AUTOSTART 1000
then
diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp
index ed090271c..ace13bb78 100644
--- a/src/modules/commander/commander.cpp
+++ b/src/modules/commander/commander.cpp
@@ -116,6 +116,8 @@ extern struct system_load_s system_load;
#define LOW_VOLTAGE_BATTERY_COUNTER_LIMIT (LOW_VOLTAGE_BATTERY_HYSTERESIS_TIME_MS*COMMANDER_MONITORING_LOOPSPERMSEC)
#define CRITICAL_VOLTAGE_BATTERY_COUNTER_LIMIT (CRITICAL_VOLTAGE_BATTERY_HYSTERESIS_TIME_MS*COMMANDER_MONITORING_LOOPSPERMSEC)
+#define MAVLINK_OPEN_INTERVAL 50000
+
#define STICK_ON_OFF_LIMIT 0.75f
#define STICK_THRUST_RANGE 1.0f
#define STICK_ON_OFF_HYSTERESIS_TIME_MS 1000
@@ -582,16 +584,6 @@ int commander_thread_main(int argc, char *argv[])
mavlink_fd = open(MAVLINK_LOG_DEVICE, 0);
- if (mavlink_fd < 0) {
- /* try again later */
- usleep(20000);
- mavlink_fd = open(MAVLINK_LOG_DEVICE, 0);
-
- if (mavlink_fd < 0) {
- warnx("ERROR: Failed to open MAVLink log stream again, start mavlink app first.");
- }
- }
-
/* Main state machine */
/* make sure we are in preflight state */
memset(&status, 0, sizeof(status));
@@ -770,6 +762,11 @@ int commander_thread_main(int argc, char *argv[])
while (!thread_should_exit) {
+ if (mavlink_fd < 0 && counter % (1000000 / MAVLINK_OPEN_INTERVAL) == 0) {
+ /* try to open the mavlink log device every once in a while */
+ mavlink_fd = open(MAVLINK_LOG_DEVICE, 0);
+ }
+
/* update parameters */
orb_check(param_changed_sub, &updated);