geekfactory / shell Goto Github PK
View Code? Open in Web Editor NEWGeekFactory Shell Library - Library to create a simple Command Line Interface (CLI).
License: GNU General Public License v3.0
GeekFactory Shell Library - Library to create a simple Command Line Interface (CLI).
License: GNU General Public License v3.0
When too many arguments are given to a command the parser can write outside of the argument pointer array causing memory corruption and unpredictable behavior.
Parameter limit is set in Shell.h and by default is 10.
The Arduino IDE generates a compile error when building for ESP8266. I will generate a pull request to fix. The issue is around the strncmp call when using the ESP8266 core. I am currently using 2.4.0-RC2. I was able to confirm the error persists with 2.4.0-RC1 as well.
Getting this warning at compile time. Thought you should know:
lib/GeekFactory Shell Library_ID1946/Shell.c:270:22: warning: variable 'retval' set but not used [-Wunused-but-set-variable]
unsigned int i = 0, retval = 0;
Using Shell as a "library" within PlatformIO, I tried #define CONFIG_SHELL_MAX_COMMANDS 10
before #include <Shell.h>
, but it seems like this define is either being ignored, or is somehow executed AFTER the #include. Not sure what's going on, but short of editing Shell.h, there is no way to support more than 5 shell commands. (shell_register returns false for any command beyond the first 5).
I'd like to implement a command history feature. I imagine it would work similarly to other command shells, where the up and down arrow keys cycle through recently used commands. The user would have the option of making changes to a previous command's arguments before running it again. This may also lead to implementing the left and right arrow keys, allowing the user to move a cursor left and right when typing a command.
I expect this feature will require a significant amount of memory to be used, around 700 bytes for a 10 item long history list. This much memory usage only makes sense on larger modules (Arduino Mega, ESP8266, etc.), so this feature should be disabled by default and enabled via a macro in the Shell.h file.
I'm happy to implement this feature myself, but I'm curious if the community has input on how this feature would work?
shell_putc()
calls both shell_writer(
) and obhandle->shell_bwriter()
if both are not 0. This results in chars being printed twice, once by each writer. There is no way to avoid this condition when using buffered output, since shell_writer()
is required by shell_init()
and there's no way to undefined it.
Steps to reproduce:
--Initialize the shell as in the Shell_Basic example
--Add a buffered writer, something like:
void shell_buffered_writer(char* buffer, uint8_t count)
{
// If we can write to a client
if(client==true && client.connected())
{
client.write(buffer, count);
}
}
--Write enough output with shell_print()
to trigger a buffered write
--Observe that the output is written twice
Proposed solution:
Rework the if
statements in shell_putc()
so that only one writer is called
so i build a code for esp32 dev kit v1. where my command was sendpayload JSONVALUE 1
so there two argument json and 1. 1 is bool so its won't affect game starts when json value's size increase to 285 so at the size of 286 esp32 hangs up and no code is being excecute. please help
Calling shell_print_commands()
causes a crash. On my ESP8266 module, this manifests as a reboot with an exception cause of 3 (LoadStoreErrorCause). I believe this is caused by using PSTR()
to store command strings in PROGMEM/flash, and then trying to print them with shell_println()
instead of shell_println_pm()
. I believe Arduino boards like the Uno and Mega would be affected by this as well, but don't have one to test with.
Steps to reproduce:
--Register a command with the command wrapped in a PSTR()
call. e.g. shell_register(command_mycommand, PSTR("mycommand"));
--Call shell_print_commands()
I was using PSTR()
because its what is done in the examples, and seems to be what the library expects. I have plenty of RAM available on my module, so I've moved away from the PSTR()
calls as a temporary solution and things are working. However, it seems cleaner to fix this issue by adding an #ifdef ARDUINO
wrapper to the shell_print_commands()
function's loop so that the correct print_ln function gets called.
I get the following errors when building:
In file included from C:\users\fgka\.platformio\packages\framework-arduinoststm32-maple\STM32F1\cores\maple/wirish.h:58:0,
from C:\users\fgka\.platformio\packages\framework-arduinoststm32-maple\STM32F1\cores\maple/Arduino.h:30,
from .pio\libdeps\sam_v1\GeekFactory Shell Library_ID1946\Shell.h:31,
from .pio\libdeps\sam_v1\GeekFactory Shell Library_ID1946\Shell.c:20:
C:\users\fgka\.platformio\packages\framework-arduinoststm32-maple\STM32F1\cores\maple/ext_interrupts.h:90:6: error: conflicting types for 'attachInterrupt'
void attachInterrupt(uint8 pin, voidArgumentFuncPtr handler, void *arg,
^~~~~~~~~~~~~~~
C:\users\fgka\.platformio\packages\framework-arduinoststm32-maple\STM32F1\cores\maple/ext_interrupts.h:69:6: note: previous declaration of 'attachInterrupt' was here
void attachInterrupt(uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode);
^~~~~~~~~~~~~~~
Arduino Maple core for STM32 is incompatible with C.
If I rename Shell.c
to Shell.cpp
, the problem goes away. The compiler builds everything in CPP mode then.
how to reproduce:
On a command that requires at least one argument, enter two spaces instead of one in between the command and the argument.
Thanks for the very nice software
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.