diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-26 07:43:19 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-26 07:43:19 +0100 |
commit | cbcd1ea1d143dfddd2331fb14d17d7be48fa8b6f (patch) | |
tree | 5be46ffd492dd3980ccfb3b7303238d22a22ff6c /src/systemcmds/nshterm | |
parent | 739c407cfd14d065b104977924875b3ee40d5e25 (diff) | |
parent | 4724c050478900a0b0b760877f1613e43c0aa97c (diff) | |
download | px4-firmware-cbcd1ea1d143dfddd2331fb14d17d7be48fa8b6f.tar.gz px4-firmware-cbcd1ea1d143dfddd2331fb14d17d7be48fa8b6f.tar.bz2 px4-firmware-cbcd1ea1d143dfddd2331fb14d17d7be48fa8b6f.zip |
Merged PX4Flow driver changes
Diffstat (limited to 'src/systemcmds/nshterm')
-rw-r--r-- | src/systemcmds/nshterm/module.mk | 2 | ||||
-rw-r--r-- | src/systemcmds/nshterm/nshterm.c | 31 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/systemcmds/nshterm/module.mk b/src/systemcmds/nshterm/module.mk index 41706e137..a12bc369e 100644 --- a/src/systemcmds/nshterm/module.mk +++ b/src/systemcmds/nshterm/module.mk @@ -41,3 +41,5 @@ SRCS = nshterm.c MODULE_STACKSIZE = 1600 MAXOPTIMIZATION = -Os + +MODULE_PRIORITY = "SCHED_PRIORITY_DEFAULT-30" diff --git a/src/systemcmds/nshterm/nshterm.c b/src/systemcmds/nshterm/nshterm.c index fca1798e6..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); @@ -87,7 +110,7 @@ nshterm_main(int argc, char *argv[]) /* Back up the original uart configuration to restore it after exit */ if ((termios_state = tcgetattr(fd, &uart_config)) < 0) { - warnx("ERROR get termios config %s: %d\n", argv[1], termios_state); + warnx("ERR get config %s: %d\n", argv[1], termios_state); close(fd); return -1; } @@ -96,7 +119,7 @@ nshterm_main(int argc, char *argv[]) uart_config.c_oflag |= (ONLCR | OPOST/* | OCRNL*/); if ((termios_state = tcsetattr(fd, TCSANOW, &uart_config)) < 0) { - warnx("ERROR setting baudrate / termios config for %s (tcsetattr)\n", argv[1]); + warnx("ERR set config %s\n", argv[1]); close(fd); return -1; } |