aboutsummaryrefslogtreecommitdiff
path: root/src/systemcmds/nshterm/nshterm.c
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2014-11-24 07:41:26 +0100
committerThomas Gubler <thomasgubler@gmail.com>2014-11-24 07:41:26 +0100
commitc37ff71e625310cdc777719a04c3702d9afa1f7f (patch)
tree714ecb7b510e7ff53080ce3f0caebe8b128a26f5 /src/systemcmds/nshterm/nshterm.c
parentf36f54c621cb5b36d345c5a26f72e89fc948fa65 (diff)
parent512779907e06f059a15d54c88d71b73aad9aced0 (diff)
downloadpx4-firmware-c37ff71e625310cdc777719a04c3702d9afa1f7f.tar.gz
px4-firmware-c37ff71e625310cdc777719a04c3702d9afa1f7f.tar.bz2
px4-firmware-c37ff71e625310cdc777719a04c3702d9afa1f7f.zip
Merge remote-tracking branch 'upstream/master' into ros
Conflicts: makefiles/config_px4fmu-v2_test.mk
Diffstat (limited to 'src/systemcmds/nshterm/nshterm.c')
-rw-r--r--src/systemcmds/nshterm/nshterm.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/systemcmds/nshterm/nshterm.c b/src/systemcmds/nshterm/nshterm.c
index f06c49552..edeb5c624 100644
--- a/src/systemcmds/nshterm/nshterm.c
+++ b/src/systemcmds/nshterm/nshterm.c
@@ -51,6 +51,8 @@
#include <fcntl.h>
#include <systemlib/err.h>
+#include <uORB/topics/actuator_armed.h>
+
__EXPORT int nshterm_main(int argc, char *argv[]);
int
@@ -62,9 +64,30 @@ nshterm_main(int argc, char *argv[])
}
unsigned retries = 0;
int fd = -1;
+ int armed_fd = orb_subscribe(ORB_ID(actuator_armed));
+ struct actuator_armed_s armed;
+ /* we assume the system does not provide arming status feedback */
+ bool armed_updated = false;
+
+ /* try the first 30 seconds or if arming system is ready */
+ while ((retries < 300) || armed_updated) {
+
+ /* abort if an arming topic is published and system is armed */
+ bool updated = false;
+ if (orb_check(armed_fd, &updated)) {
+ /* the system is now providing arming status feedback.
+ * instead of timing out, we resort to abort bringing
+ * up the terminal.
+ */
+ armed_updated = true;
+ orb_copy(ORB_ID(actuator_armed), armed_fd, &armed);
+
+ if (armed.armed) {
+ /* this is not an error, but we are done */
+ exit(0);
+ }
+ }
- /* try the first 30 seconds */
- while (retries < 300) {
/* the retries are to cope with the behaviour of /dev/ttyACM0 */
/* which may not be ready immediately. */
fd = open(argv[1], O_RDWR);