port http://sourceforge.net/projects/tinysh to mbed enviroment
Dependents: kl25z-tinyshell-demo HelloWorld_IHM02A1
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() ); } }
Revision 1:71580bf962fe, committed 2014-03-11
- Comitter:
- murilopontes
- Date:
- Tue Mar 11 05:19:36 2014 +0000
- Parent:
- 0:78b46c0d5246
- Commit message:
- update \r e \n
Changed in this revision
tinysh.c | Show annotated file Show diff for this revision Revisions of this file |
diff -r 78b46c0d5246 -r 71580bf962fe tinysh.c --- a/tinysh.c Tue Mar 11 03:49:18 2014 +0000 +++ b/tinysh.c Tue Mar 11 05:19:36 2014 +0000 @@ -440,14 +440,14 @@ { if(_str_len==common_len) { - putchar('\n'); + puts("\r\n"); for(cm=cmd;cm;cm=cm->next) { int r=strstart(cm->name,__str); if(r==FULLMATCH || r==PARTMATCH) { puts(cm->name); - putchar('\n'); + puts("\r\n"); } } return 1;