Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Feb 10, 2024. It is now read-only.
/ushellPublic archive

Microshell is a small shell for embedded systems written in C89 without dynamic memory allocations and libc (freestanding)

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

ilya-sotnikov/ushell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microshell is a small shell for embedded systems written in C89 without dynamic memory allocations and libc (freestanding).

Example

You can provide any commands.

ushell: commands available:test - prints "test"print_args - prints all argsadd2ints - adds 2 int argshelp - list all commands$ add2ints 1 21 + 2 = 3

Usage

tl;dr ->arduino port

  1. Add ushell.c and ushell.h to your project and #include "ushell.h".
  2. Define a function to transmit 1 char (byte) over the interface of your choice (UART, I2C, SPI, etc.). Don't redeclare it.
voidushell_putchar(charchr);
  1. Provide a command list (name, description, function). Functions must have this prototype:
voidfunction_name(intargc,char*argv[]);
  1. Initialize ushell like this:
staticconstushell_command_tcommands[]= {        {"test","prints \"test\"",&test },        {"print_args","prints all args",&print_args },        {"add2ints","adds 2 int args",&add2ints },};ushell_init(commands,sizeof(commands) /sizeof(commands[0]));

commands[] array should not be destroyed if it's allocated in a local stack frame so it's a good idea to addstatic.

Also, since the array size is calculated using the sizeof operator, you should call ushell_init() where you declare commands[].

  1. Call this function when new data is available in the interface of your choice.
voidushell_process(charchr);

You can check examples from the "port" directory.

If you are building it on PC using cmake it just runs tests in main.c. To build and run tests (usingUnity):

  1. git clone https://github.com/ilya-sotnikov/ushell
  2. cd ushell
  3. mkdir build && cd build
  4. cmake -DCMAKE_BUILD_TYPE=Debug -G Ninja ../src && cmake --build .
  5. ./ushell

If you use it for MCUs there's anarduino port you can use as an example.

There's also an implicit "help" function which prints all available functions and their descriptions.

Microshell should work basically everywhere (if there is a C compiler).

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in the work by you, as defined in the Apache-2.0 license, shall bedual licensed as above, without any additional terms or conditions.

Feel free to add features or fix bugs. This project uses the Linux kernel coding style, youcan use the .clang-format file fromhere.

Debug build uses sanitizers (address, undefined, leak) by default.

About

Microshell is a small shell for embedded systems written in C89 without dynamic memory allocations and libc (freestanding)

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp