Enable programmatic termination of shell Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
User avatar
FXCoder
Posts: 135
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 37 times
Been thanked: 36 times

Enable programmatic termination of shell  Topic is solved

Postby FXCoder » Thu Apr 19, 2018 2:11 pm

Small change to enable a software shell terminate request to be issued.
I've implemented this change to shell.c for an SDU use case where status output is directed to SDU.
Output to SDU is paused when a shell session is requested (by hitting a key on terminal).
After shell commands, etc. are finished the shell is normally terminated by 'exit' or ^D by the user.
However, when an SDU disconnect event happens due to USB SUSPEND then the shell can be programmatically terminated.

Code: Select all

Index: shell.c
===================================================================
--- shell.c   (revision 11940)
+++ shell.c   (working copy)
@@ -354,7 +354,7 @@
 
   chprintf(chp, SHELL_NEWLINE_STR);
   chprintf(chp, "ChibiOS/RT Shell" SHELL_NEWLINE_STR);
-  while (true) {
+ while (!chThdShouldTerminateX()) {
     chprintf(chp, SHELL_PROMPT_STR);
     if (shellGetLine(scfg, line, sizeof(line), shp)) {
 #if (SHELL_CMD_EXIT_ENABLED == TRUE) && !defined(_CHIBIOS_NIL_)

User avatar
FXCoder
Posts: 135
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 37 times
Been thanked: 36 times

Re: Enable programmatic termination of shell

Postby FXCoder » Tue Jun 19, 2018 12:32 pm

Bump...

User avatar
Giovanni
Site Admin
Posts: 11385
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 430 times
Been thanked: 363 times
Contact:

Re: Enable programmatic termination of shell

Postby Giovanni » Sun Jul 08, 2018 6:58 am

Hi,

Added to trunk and 18.2.

Giovanni

sabdulqadir
Posts: 12
Joined: Fri Mar 23, 2018 7:29 pm
Has thanked: 6 times
Been thanked: 2 times

Re: Enable programmatic termination of shell

Postby sabdulqadir » Thu Nov 22, 2018 12:30 am

Just to make sure, this means the shell would terminate when the USB device is detached?
Would you guys be able to tell who is requesting the termination?
Thanks,
AQ

User avatar
FXCoder
Posts: 135
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 37 times
Been thanked: 36 times

Re: Enable programmatic termination of shell

Postby FXCoder » Thu Nov 22, 2018 8:31 am

Hi,
In RT shell can be terminated by:
1. A channel reset or input of ^D to the shell
2. Entering the "exit" command (if enabled) to shell.
3. By another thread signaling for shell to terminate at next loop with chThdTerminate(...)

In all cases the exit is via shellExit(MSG_OK) which broadcasts a non-specific event and returns MSG_OK as its termination status.

So bottom line is, as currently implemented, you won't know which of the above triggered the termination.


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 1 guest