aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2015-01-22 08:30:18 +0100
committerLorenz Meier <lm@inf.ethz.ch>2015-01-22 08:30:18 +0100
commit26d46239dcb6f6791e837d1f36b9205681d65e18 (patch)
tree77ab47b2126f53eee40f51db3594a1e1e0efc6f7
parent38ae6bcc5fd5e9ab1a7304140ec6b36ff027625f (diff)
downloadpx4-firmware-26d46239dcb6f6791e837d1f36b9205681d65e18.tar.gz
px4-firmware-26d46239dcb6f6791e837d1f36b9205681d65e18.tar.bz2
px4-firmware-26d46239dcb6f6791e837d1f36b9205681d65e18.zip
top cmd: Introduce non-standard --once option for test systems
-rw-r--r--src/systemcmds/top/top.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/systemcmds/top/top.c b/src/systemcmds/top/top.c
index 37e913040..ababbadf4 100644
--- a/src/systemcmds/top/top.c
+++ b/src/systemcmds/top/top.c
@@ -56,7 +56,7 @@
/**
* Start the top application.
*/
-__EXPORT int top_main(void);
+__EXPORT int top_main(int argc, char *argv[]);
extern struct system_load_s system_load;
@@ -89,7 +89,7 @@ tstate_name(const tstate_t s)
}
int
-top_main(void)
+top_main(int argc, char *argv[])
{
uint64_t total_user_time = 0;
@@ -107,6 +107,13 @@ top_main(void)
float interval_time_ms_inv = 0.f;
+ bool once = false;
+
+ if (argc > 1) {
+ /* non-standard once argument: Prints load once and exits */
+ once = !strcmp(argv[1], "--once");
+ }
+
/* clear screen */
printf("\033[2J");
@@ -252,6 +259,10 @@ top_main(void)
interval_start_time = new_time;
+ if (once) {
+ return OK;
+ }
+
/* Sleep 200 ms waiting for user input five times ~ 1s */
for (int k = 0; k < 5; k++) {
char c;