Browse Source

POSIX: Improve shell so it does not spam the user, enable CTRL-C to actually quit the application. Twiddle the app boot delay to avoid a race with the commander app. Needs a proper fix on the startup sequencing.

sbg
Lorenz Meier 10 years ago
parent
commit
54209af679
  1. 35
      src/platforms/posix/main.cpp
  2. 4
      src/platforms/posix/px4_layer/px4_posix_tasks.cpp

35
src/platforms/posix/main.cpp

@ -65,11 +65,15 @@ extern "C" { @@ -65,11 +65,15 @@ extern "C" {
}
}
static void print_prompt()
{
cout << "pxh> ";
}
static void run_cmd(const vector<string> &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<string> &appargs) @@ -82,15 +86,20 @@ static void run_cmd(const vector<string> &appargs)
}
arg[i] = (char *)0;
cout << "Running: " << command << "\n";
apps[command](i, (char **)arg);
usleep(40000);
cout << "Returning: " << command << "\n";
usleep(45000);
} else {
cout << "Invalid command: " << command << endl;
} else if (command.compare("help") == 0) {
list_builtins();
} else if (command.length() == 0) {
// Do nothing
} else {
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) @@ -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;
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);
}
}

4
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 @@ -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) @@ -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;

Loading…
Cancel
Save