How can I use the CLI - Can't get any commands to run


I'm trying to inject some aux data in using the debug port, I've CLI #defined'ed in main.c, and I get the "i0>" carrot on the serial interface, but I can't get it to respond to any commands.

//Command table
// {char *name, tShellCallback callback, uint32_t callbackData, const *help }
const tCommand gCommands[] =
  {"ver",      &CmdVersion,                0, "Display firmware version"},
  {"raccel",   &CmdReadAccelerometer,      0, "Read accelerometer"},
  {"rgyro",    &CmdReadGyro,               0, "Read Gyro"},
  {"rmag",     &CmdReadMagnetometer,       0, "Read magnetometer"},
//  {"rGPS",     &CmdGpsRead, 0,  "Read current GPS value" },

The CLI will echo all my chars, and send a "bell" when i exceed buff size. I just can't get it to process any command, clearly I'm missing something.

Seems like I should just type "ver" and get something like "OpenIMU300ZA 5020-3885-01 1.0.22 SN:1808400XXX" out.

What terminates a command?


I had the same problem, after looking at the code I thinks it's design is only for Windows with cr/lf and I am using linux terminal that only sends cr. I think it might be better for it to detect cr as end of line not LF.

Regardless of that I don't see how the code ever worked properly, as the static uint32_t index = 0; and cmdlinde are never reset after am initial command line execution.

I added bzero(&gCmdLine[0], sizeof(gCmdLine); index = 0 in (commandline.c)

If you don't reset the above then it will only ever run one command.

void CmdLineLookup(tCommand const *cmd_table)
static uint32_t index = 0;

if (DebugSerialReadLine((uint8_t*) gCmdLine, &index, 80)) {
    strrep(gCmdLine, '\r', 0);
    strrep(gCmdLine, '\n', 0);
    if (gCmdLine[0]) {//don't process empty string
        //Ignore lines that start with # character
        if (gCmdLine[0] != '#') {
    bzero(&gCmdLine[0], sizeof(gCmdLine)); // Add this
    index = 0; // And this

} // else wait until prompt is ready


Also comment the following in Debug_usart.c as it is stripping out the cr so it will never find the end of line to and never return true from DebugSerialReadLine()

int DebugSerialReadLine(uint8_t *buf, uint32_t *index, uint32_t len)
uint8_t c = 0, lf = 0;
int num;

while (c != _LF){
    num = uart_read(debugSerialChan, &c, 1);
    if(num <= 0){
    if (_TAB == c) {
        c = _SPACE;
    /*if (_CR == c) {  // comment this out



Log in to reply