Page 1 of 2

Questions about the shell

Posted: Tue Aug 23, 2016 9:30 pm
by meatball
Are there any examples of complete feature use for the shell? I've not found any.

I only see the examples of the main() function starting the shell thread and then basically letting it spin.

Functions as described in the Shell Enhancements post: http://www.chibios.com/forum/viewtopic.php?f=24&t=3293

look to be useful, but I cannot get any of the them to function as intended simply by enabling them in shell.h

These functions require various other structs of various kinds. Does anyone have a full example code snippet showing some of these structures initalized or declared?

Most of the examples online are from older shell versions. Functions that no longer exist in the trunk are always used in them.

Re: Questions about the shell

Posted: Wed Aug 24, 2016 6:36 am
by Giovanni
Hi,

Shell demos in trunk do not use completion by default, you just need to enable it and add the extra info (a buffer) into the shell configuration structure.

Code: Select all

/**
 * @brief   Shell descriptor type.
 */
typedef struct {
  BaseSequentialStream  *sc_channel;        /**< @brief I/O channel associated
                                                 to the shell.              */
  const ShellCommand    *sc_commands;       /**< @brief Shell extra commands
                                                 table.                     */
#if (SHELL_USE_HISTORY == TRUE) || defined(__DOXYGEN__)
  char                  *sc_histbuf;        /**< @brief Shell command history
                                                 buffer.                    */
  const int             sc_histsize;        /**< @brief Shell history buffer
                                                 size.                      */
#endif
#if (SHELL_USE_COMPLETION == TRUE) || defined(__DOXYGEN__)
  char                  **sc_completion;    /**< @brief Shell command completion
                                                 buffer.                    */
#endif
} ShellConfig;


Giovanni

Re: Questions about the shell

Posted: Thu Aug 25, 2016 4:21 pm
by meatball
Is there list of commands to use this features?

The arrows on my keyboard don't seem to do anything, and the tab key doesn't yield any response either.

Re: Questions about the shell

Posted: Thu Aug 25, 2016 6:01 pm
by Giovanni
You need to set SHELL_USE_COMPLETION, SHELL_USE_ESC_SEQ and SHELL_USE_HISTORY to TRUE.

Try CTRL-N and CTRL-P for history too.

Giovanni

Re: Questions about the shell

Posted: Sat Oct 15, 2016 2:45 am
by Chudik
Giovanni
I used shell in my previous design and definitely want to use it again.
I included shell.h in my main.c and compiler has no objection about that.
However, when I add call of shellInit(); it gives me the error message

D:\TMP\cconOoqt.ltrans0.ltrans.o: In function `main':
D:\Designs\Firmware\CH_M3DisplayEval/main.c:49: undefined reference to `shellInit'
collect2.exe: error: ld returned 1 exit status
make: *** [build/ch_m3displayeval.elf] Error 1


What do I do wrong? Should I copy shell.c and shell.h inside my project or keeping them in os/various directory is ok.

And, BTW, it is the same whether I try in it ChibiStudio or in SW4STM32.

Even on favorite path C:\ChibiOS the same story
C:\ChibiStudio\chibios161\demos\STM32\RT-STM32L152RE-NUCLEO/main.c:58: undefined reference to `shellInit'
collect2.exe: error: ld returned 1 exit status
make: *** [build/ch.elf] Error 1

Re: Questions about the shell

Posted: Sat Oct 15, 2016 7:16 am
by Giovanni
Apparently the linker does not see the shell object files.

Giovanni

Re: Questions about the shell

Posted: Sat Oct 15, 2016 10:37 pm
by Chudik
I understand that. Why does it happen even at default location?

Re: Questions about the shell

Posted: Sat Oct 15, 2016 10:40 pm
by Giovanni
Is shell.c actually compiled?

Giovanni

Re: Questions about the shell

Posted: Sat Oct 15, 2016 11:15 pm
by Chudik
No :(
I thought including shell.h would be enough for the compiler to find shell.c as well

Added to Makefile

Code: Select all

include ${CHIBIOS}/os/various/shell.mk


Created shell.mk

Code: Select all

# List of all the ChibiOS/RT shell files.
SHELLSRC = ${CHIBIOS}/os/various/shell.c

# Required include directories
SHELLINC = ${CHIBIOS}/os/various/


Did not help :roll:

Re: Questions about the shell

Posted: Sat Oct 15, 2016 11:16 pm
by Giovanni
Look at the makefile of any demo using the shell and make sure to do the same, you are forgetting to expand those variables probably.

Giovanni