/* * * PRU Debug Program - command input function * (c) Copyright 2011, 2013 by Arctica Technologies * Written by Steven Anderson * */ #include #include #include #include #include #include #include #include #include #include #include #include "prudbg.h" int cmd_input(char *prompt, char *cmd, char *cmdargs, unsigned int *argptrs, unsigned int *numargs) { unsigned int i, j, full_len, on_zero; char c, last_char; char buf[MAX_COMMAND_LINE]; // print prompt printf("%s", prompt); // collect command until space or return i = 0; do { c = getchar(); // check for backspace if (c == 0x08 || c == 0x7f) { if (i != 0) { putchar(0x08); putchar(' '); putchar(0x08); i--; } // just a normal character } else { buf[i] = c; printf("%c", buf[i]); if (i < (MAX_COMMAND_LINE - 1)) i++; } } while (c != '\n'); buf[i-1] = 0; // replace spaces and return with zeros full_len = strlen(buf); for (i=0; i