Shell Component with History Function

Thanks to the contribution from [francescoaru], the Shell component has now a history function:

Shell with History

Shell with History

This means (if enabled), the Shell component remembers the last few commands. Entering any non-alpha/numeric character (e.g. TAB, CURSOR-UP/DOWN/LEFT/RIGHT, etc) will show the previous command, and you can iterate trough the list. Press Enter and it gets executed. This is especially useful if you are using a terminal program like putty without history: E.g. pressing TAB will show the previous command:

Tab to show previous command

Tab to show earlier command

Then press TAB again, or simply ENTER to execute the command. You can use the cursor up/down/left/right keys to go forward and backward in the list of history, then press ENTER to execute the command.

💡 There is one ‘not so perfect thing’: if pressing cursor-up and then cursor-down, it will show the command again. But I hope this is not a big deal, otherwise any contributions to improve this are welcome 🙂

The updated sources are on GitHub, so anyone using Git can use the new feature right away. Updated *.PEupd files with other added features will be released later this month on SourceForge.

Happy Historing 🙂

9 thoughts on “Shell Component with History Function

  1. Another useful addition!! Thanks both! I think I requested this feature after the backspace enhancement. On the basis that my wishes are granted, let me try my luck and propose:

    (a) A table-driven menu system, to replace the current code that requires multiple CLS1_SendHelpStr() lines to print the menu then UTIL1_strcmp() lines in xxx_ParseCommand(), which feels inefficient and gives quite verbose code. Maybe a list of menu strings plus a list of (string, function call) pairs to drive xxx_ParseCommand().

    (b) A merging of the CLS1_xxx() and UTIL1_xxx() print functions with the user-friendly XFormat print functions. XFormat is a great enhancement over UTIL1_xxx, but I find I am still using CLS1_SendHelpStr() and CLS1_SendStatusStr() as well. Can we consolidate?


    • Thanks for the wishes 🙂
      Actually, the wish (a) is on my list of things for a long time (to have the commands table driven). I agree, this would simplify things a lot. Additionally I’m thinking about a better way than to populate the command line handlers in the code (maybe with a dedicated component).
      About (b): The utility module has grown over time, and functions ended up there instead of creating new components. It would be easy to put the XFormat components into the Utility module, but then it would grow up even more. I was thinking that maybe a ‘Strings’ module would be more appropriate. But I fear that this might require to update a lot of projects. Maybe create that new ‘Strings’ component, and depreciate the Utility one (or map the Utility functions to the String module one, so it is backwards compatible?


      • Hi Erich

        I can understand how the components have evolved over time and that backward compatibility would be an issue. I suspect that creating a clean new component and deprecating the old one(s) would be fine, as in reality people are not going to bother to upgrade old projects. They can use the new components in new projects.

        If you are thinking about the “Strings” component then can I suggest new % specifiers that can be used to assemble binary data of different lengths, in addition to printable characters. I have been spending time assembling buffers that represent commands that I pass to a Bluetooth chip and also AT commands for a modem. The buffers contain a mixture of ASCII text and (ASCII) numbers and binary data (bytes, words, arrays of variable length). It would be great to use XF1_xsprintf() to create such buffers.

        Thanks again for your good work. Regards – Charles


  2. Pingback: McuOnEclipse Components: 03-Feb-2015 Release | MCU on Eclipse

  3. Pingback: USB CDC with the Raspberry Pi | MCU on Eclipse

  4. Hi Erich,

    Can you give some advice about how to use the shell component on S32DS 32K144, I can output the serial as printf, but when add the shell componment, nothing happened.
    Can you give some suggestion or is there a sample I can refer to ?


What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.