port http://sourceforge.net/projects/tinysh to mbed enviroment

Dependents:   kl25z-tinyshell-demo HelloWorld_IHM02A1

Homepage

This library is a port of tiny shell library to mbed enviroment.

Features

  • Autocomplete
  • Command history
  • Linux like

Tiny Shell minimal example

#include "mbed.h"
#include "tinysh.h"

//serial port to use 
Serial pc(USBTX, USBRX);

//custom function
void foo_fnt(int argc, char **argv)
{
    printf("foo command called\r\n");
    for(int i=0; i<argc; i++) {
        printf("argv[%d]=\"%s\"\r\n",i,argv[i]);
    }
}
//custom command
tinysh_cmd_t myfoocmd= {0,"foo","foo command","[args]",foo_fnt,0,0,0};



//mandatory tiny shell output function
void tinysh_char_out(unsigned char c)
{
    pc.putc(c);
}


void main(void){

   //configure serial baudrate
    pc.baud(115200);

   //print build date
    pc.printf("tiny shell build %s %s\r\n",__DATE__,__TIME__);

    //set prompt
    tinysh_set_prompt("$ ");

    //add custom commands here
    tinysh_add_command(&myfoocmd);

   //run command parser loop foverer 
    while(true) {
        tinysh_char_in( pc.getc() );
    }
}

All wikipages