1 Star 0 Fork 34

lzm2018 / nr_micro_shell

forked from Nrush / nr_micro_shell 
Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
readme.md

nr_micro_shell

中文版本

Author: Ji Youzhou

Licence: MIT

If you think this project will help you, please STAR Github or Gitee to encourage the author.

nr_micro_shell is designed to provide an interactive experience similar to the command line of Linux shell on MCU (e.g. stm32f103c8t6).

Following functions are provide:

  • Basic command line function.

  • Use the tab key to complete the command automatically.

  • Query history command with direction key.

  • Move cursor with direction key.

Attention: If you want to use the last three functions, you must use a serial terminal software that supports ANSI, such as Hypertrm.

The following is the test result under the condition of stm32f103c8t6 platform and hypertrm serial port terminal.

test

Configure:

All configuration work can be done in the nr_micro_shell_config.h. For details, see the comments in the file.

Usage:

  • Make sure all files have been added into your project.

  • Make sure the function 'printf(),putchar()' can be used in your project.

  • An example is given as follow

#include "nr_micro_shell.h"

int main(void)
{
    shell_init();

    while(1)
    {
        if(USART GET A CHAR 'c')
        {
            shell(c);
        }
    }
}

Add your own command

STEP1: You should realize a command function in nr_micro_shell_commands.c. The prototype of the command function is as follow

void your_command_funtion(char argc, char *argv)
{
    .....
}

argc is the number of parameters. argv stores the starting address and content of each parameter. If your input string is

test -a 1

then the argc will be 3 and the content of argv will be

-------------------------------------------------------------
0x03|0x08|0x0b|'t'|'e'|'s'|'t'|'\0'|'-'|'a'|'\0'|'1'|'\0'|
-------------------------------------------------------------

If you want to know the content of first or second parameter, you should use

/* "-a" */
printf(argv[argv[1]])
/* "1" */
printf(argv[argv[2]])

STEP2: Register you command in the table static_cmd[] as follow

const static_cmd_st static_cmd[] =
{
   .....
   {"your_command_name",your_command_funtion},
   .....
   {"\0",NULL}
};

Attention: DO NOT DELETE {"\0",NULL} !

Comments ( 0 )

Sign in for post a comment

About

shell for MCU. 单片机命令行交互。 spread retract
Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
1
https://gitee.com/lzm2018/nr_micro_shell.git
git@gitee.com:lzm2018/nr_micro_shell.git
lzm2018
nr_micro_shell
nr_micro_shell
master

Search