Questions about the shell

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

meatball
Posts: 32
Joined: Thu May 19, 2016 4:39 pm
Has thanked: 9 times
Been thanked: 2 times

Questions about the shell

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Questions about the shell

Post 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
meatball
Posts: 32
Joined: Thu May 19, 2016 4:39 pm
Has thanked: 9 times
Been thanked: 2 times

Re: Questions about the shell

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Questions about the shell

Post 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
User avatar
Chudik
Posts: 152
Joined: Fri Jan 16, 2015 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: Questions about the shell

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Questions about the shell

Post by Giovanni »

Apparently the linker does not see the shell object files.

Giovanni
User avatar
Chudik
Posts: 152
Joined: Fri Jan 16, 2015 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: Questions about the shell

Post by Chudik »

I understand that. Why does it happen even at default location?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Questions about the shell

Post by Giovanni »

Is shell.c actually compiled?

Giovanni
User avatar
Chudik
Posts: 152
Joined: Fri Jan 16, 2015 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: Questions about the shell

Post 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:
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Questions about the shell

Post 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
Post Reply