diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index 1c34b281af..b298da112e 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -65,11 +65,15 @@ extern "C" { } } +static void print_prompt() +{ + cout << "pxh> "; +} + static void run_cmd(const vector &appargs) { // command is appargs[0] string command = appargs[0]; - cout << "----------------------------------\n"; if (apps.find(command) != apps.end()) { const char *arg[appargs.size() + 2]; @@ -82,15 +86,20 @@ static void run_cmd(const vector &appargs) } arg[i] = (char *)0; - cout << "Running: " << command << "\n"; apps[command](i, (char **)arg); - usleep(40000); - cout << "Returning: " << command << "\n"; + usleep(45000); + + } else if (command.compare("help") == 0) { + list_builtins(); + + } else if (command.length() == 0) { + // Do nothing } else { - cout << "Invalid command: " << command << endl; - list_builtins(); + cout << "Invalid command: " << command << "\ntype 'help' for a list of commands" << endl; + } + print_prompt(); } static void usage() @@ -177,16 +186,26 @@ int main(int argc, char **argv) if (!daemon_mode) { string mystr; + print_prompt(); + while (!_ExitFlag) { - cout << "Enter a command and its args:" << endl; - getline(cin, mystr); - process_line(mystr); - mystr = ""; + + struct pollfd fds; + int ret; + fds.fd = 0; /* stdin */ + fds.events = POLLIN; + ret = poll(&fds, 1, 100); + + if (ret > 0) { + getline(cin, mystr); + process_line(mystr); + mystr = ""; + } } } else { while (!_ExitFlag) { - sleep(1000000); + usleep(100000); } } diff --git a/src/platforms/posix/px4_layer/px4_posix_tasks.cpp b/src/platforms/posix/px4_layer/px4_posix_tasks.cpp index 129709d3d7..c8f8d801c5 100644 --- a/src/platforms/posix/px4_layer/px4_posix_tasks.cpp +++ b/src/platforms/posix/px4_layer/px4_posix_tasks.cpp @@ -143,7 +143,7 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int // Must add NULL at end of argv taskdata->argv[argc] = (char *)0; - PX4_WARN("starting task %s", name); + PX4_DEBUG("starting task %s", name); rv = pthread_attr_init(&attr); if (rv != 0) { @@ -203,7 +203,7 @@ int px4_task_delete(px4_task_t id) { int rv = 0; pthread_t pid; - PX4_WARN("Called px4_task_delete"); + PX4_DEBUG("Called px4_task_delete"); if (id < PX4_MAX_TASKS && taskmap[id].isused) pid = taskmap[id].pid;