Thanks to the contribution from [francescoaru], the Shell component has now a history function:
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:
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 🙂
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?
LikeLike
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?
LikeLike
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
LikeLike
Hi Charles,
the xprintf() is originated by Mario Viara (https://github.com/MarioViara/xprintfc). Do you already have an implementation he could use/add of your new modifiers?
LikeLike
Sorry, no.Just thought about it.
LikeLike
Pingback: McuOnEclipse Components: 03-Feb-2015 Release | MCU on Eclipse
Pingback: USB CDC with the Raspberry Pi | MCU on Eclipse
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 ?
LikeLike
You might have a look at the shell usage in https://github.com/ErichStyger/McuMiniSumoRobot/blob/master/Software/RoboLib/Shell.c
LikeLike