- Notifications
You must be signed in to change notification settings - Fork1
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
ilya-sotnikov/ushell
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Microshell is a small shell for embedded systems written in C89 without dynamic memory allocations and libc (freestanding).
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
tl;dr ->arduino port
- Add ushell.c and ushell.h to your project and #include "ushell.h".
- 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);
- Provide a command list (name, description, function). Functions must have this prototype:
voidfunction_name(intargc,char*argv[]);
- 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[].
- 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):
git clone https://github.com/ilya-sotnikov/ushell
cd ushell
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -G Ninja ../src && cmake --build .
./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).
Licensed under either of
- Apache License, Version 2.0(LICENSE-APACHE orhttp://www.apache.org/licenses/LICENSE-2.0)
- MIT license(LICENSE-MIT orhttp://opensource.org/licenses/MIT)at your option.
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)