Giter Site home page Giter Site logo

farly7 / embedded-cli Goto Github PK

View Code? Open in Web Editor NEW
104.0 4.0 23.0 22 KB

A simple command-line interface for use in embedded systems.

License: MIT License

C 100.00%
command-line-interface command-line-tool cli embedded embedded-systems command-line command commandline-interface command-parser embedded-cli

embedded-cli's Introduction

Super Loop Example/Template

A very simple template of a super loop which is used to process events in an embedded system.

embedded-cli's People

Contributors

farly7 avatar matten-ametek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

embedded-cli's Issues

Variables changed in interrupt handler are not marked as volatile

The documentation says to call the cli_put() function "within the devices interrupt handler", and "periodically call the cli_process() function", presumably from outside that interrupt handler. That being the case, shouldn't all variables written by cli_put() be marked as volatile?

README cmd_cnt initialization wrong?

From example:
.cmd_cnt = sizeof(cmds)
But this gives the size of entire cmds structure, not the number of commands. I guess it should be something like
.cmd_cnt = sizeof(cmds) / sizeof(cmd_t)

Backspace character not decrementing the buffer properly

Hello,

I am using your library with a NUCLEO-G071RB dev kit and when I use a backspace, the cli buffer is not properly decremented.

For example :

echo on ->backspace -> n will not yield "echo on" but "echo on\127n"

If I add 0x7F (delete ascii char) to the switch case in cli_put(), it works properly.

cli_status_t cli_put(cli_t *cli, char c)
{
	switch(c) {
	case CMD_TERMINATOR:

		if(!cmd_pending) {
			*buf_ptr = '\0';      /* Terminate the msg and reset the msg ptr.      */
			strcpy(cmd_buf, buf); /* Copy string to command buffer for processing. */
			cmd_pending = 1;
			buf_ptr = buf; /* Reset buf_ptr to beginning.                   */
		}
		break;

	case '\b':
	case 0x7F: // <- If I add this, backspace works properly
		/* Backspace. Delete character. */
		if(buf_ptr > buf)
			buf_ptr--;
		break;

	default:
		/* Normal character received, add to buffer. */
		if((buf_ptr - buf) < MAX_BUF_SIZE)
			*buf_ptr++ = c;
		else
			return CLI_E_BUF_FULL;
		break;
	}
	return CLI_OK;
}

I am not sure in which case the delete ascii would be treated differently, so I leave it up to you to add this fix or not.

Multiple wrong commands until carriage return is sent

If cli_process() is called periodically and it is called while the command is not complete, the message CMD: Command not recognised appears.

Is not more convenient to modify cli_put so that it calls cli_process() when CMD_TERMINATOR is received?

    case '\r':
        
        *buf_ptr = '\0';            /* Terminate the msg and reset the msg ptr.      */
        strcpy(cmd_buf, buf);       /* Copy string to command buffer for processing. */
        buf_ptr = buf;              /* Reset buf_ptr to beginning.                   */
        cli_print(cli, cli_prompt); /* Print the CLI prompt to the user.             */
        cli_process(cli);
        break;

In the same manner, in the case statement it would be more convenient to use CMD_TERMINATOR instead of '\r'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.