Command line sample code to accept custom command as input

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Command line sample code to accept custom command as input

Postby Ritesh » Thu Dec 22, 2016 6:31 pm

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..
Regards,
Ritesh Prajapati

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

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

Postby kolban » Thu Dec 22, 2016 6:46 pm

Howdy Ritesh,
Does your question substantially differ from this one:

http://esp32.com/viewtopic.php?f=2&t=732
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

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

Postby Ritesh » Thu Jan 19, 2017 1:49 pm

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.
Regards,
Ritesh Prajapati

User avatar
rudi ;-)
Posts: 1731
Joined: Fri Nov 13, 2015 3:25 pm

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

Postby rudi ;-) » Thu Jan 19, 2017 5:15 pm

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 ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Who is online

Users browsing this forum: Google [Bot] and 72 guests