Page 1 of 1

Command line sample code to accept custom command as input

Posted: Thu Dec 22, 2016 6:31 pm
by Ritesh
Hi,

Does anyone has implemented commadline input based sample code in which system is waiting to accept input from user on terminal and based on input system will parse it and perform operation as per command.? This is something like redline library used in Linux System.

Please let me know if anyone has implemented that type of command line application into ESP32..

Re: Command line sample code to accept custom command as input

Posted: Thu Dec 22, 2016 6:46 pm
by kolban
Howdy Ritesh,
Does your question substantially differ from this one:

http://esp32.com/viewtopic.php?f=2&t=732

Re: Command line sample code to accept custom command as input

Posted: Thu Jan 19, 2017 1:49 pm
by Ritesh
Hi,

Please let me know if anyone has implemented such kind of command line code which will ask for input and will perform operation for WiFi or UART or other interface test-cases based on input.

As I have checked with scanf function but some how its not working as not able to stop execution process where I have put scanf function.

So, if anyone has any idea instead of scanf to create any command line application then please let me know.

Re: Command line sample code to accept custom command as input

Posted: Thu Jan 19, 2017 5:15 pm
by rudi ;-)
Ritesh wrote:Hi,

Please let me know if anyone has implemented such kind of command line code which will ask for input and will perform operation for WiFi or UART or other interface test-cases based on input.

As I have checked with scanf function but some how its not working as not able to stop execution process where I have put scanf function.

So, if anyone has any idea instead of scanf to create any command line application then please let me know.
hi
like Neil mentioned its a good start for go.

where is the problem in your code or hang ritesh?
where you can not go on?

i understand , that you want build "Telnet" like console command app,
so you need uart and isr on Rx example if you want communicate by uart.

check the incomming char on isr and make char++ while for end char what you want example \n
after this, you can check the buffer what user have give as input.

with this check you can work then with the "request" buffer and do the things what you want to do
example ping a client.

the response you can refer to the user console example.

you can build a long command list like "AT Commands"
this you can enumerate and switch this idx to the case for the command.

not sure, what you mean with "scanf" problem :)
the char comes with the isr on Rx example, you need only read this char on each isr. ( uart )


if you mean, you want build a wifi console ( Telnet service )
than you can do the same with the recv buffer on wifi.

best wishes
rudi ;-)