![]() |
GM6000 Digital Heater Controller Build: 20 (Branch = develop)
SDX-1330
|
This concrete class provides the implementation of Command Processor for a TShell engine. More...
This concrete class provides the implementation of Command Processor for a TShell engine.
The implementation assumes a single threaded model, i.e. the Command Processor and all of its commands run in a single thread. It is APPLICATION's responsibility to provide any desired multi-threaded support. There are two caveats to the single-threaded model:
o The output of the commands are mutex protected. This allows the Output stream to be 'shared' with other sub-systems and/or threads (e.g. the shell shares the same Output stream as the Cpl::System::Trace logging output). o The stop() method can be called safely from other threads.
Commands have the following syntax:
o A command starts with a printable ASCII character and ends with a newline. o Non-printable ASCII characters are not allowed. o Any line that starts with a '#' is treated as comment line and is ignored. o Format of a command is: verb [arg]* where the verb and arguments are separated by spaces. Arguments can contain spaces character by enclosing the argument with double quote characters. A double quote character can be embedded inside a quoted string by preceding it the double quote character with the escape character. The escape character can be embedded by escaping the escape character.
The USE_CPL_TSHELL_PROCESSOR_SILENT_WHEN_PUBLIC switch is use to alter the TShell's output behavior - to not 'say anything' until a user has successfully been authenticated (using the 'User' command
HOW TO Enable Security:
- Set OPTION_TSHELL_CMD_COMMAND_DEFAULT_PERMISSION_LEVEL to something other than ePUBLIC. This will be the permission for all legacy (i.e. not Security aware) TShell commands - Recommend turning on the switch: USE_CPL_TSHELL_PROCESSOR_SILENT_WHEN_PUBLIC - Include the Cpl::TShell::Cmd::User command and provide an implementation of the Cpl::TShell::Security interface (that is passed to the command's constructor). - Optionally include new security aware commands
#include <Processor.h>
Protected Member Functions | |
| virtual Command::Result_T | executeCommand (char *deframedInput, Cpl::Io::Output &outfd) noexcept |
| Helper method that attempts to execute the content of the de-framed/decoded 'inputString'. | |
| bool | outputCommandError (Command::Result_T result, const char *deframedInput) noexcept |
| Helper method. | |
| int | getAndProcessFrame (Cpl::Io::Output &outfd) noexcept |
| Helper method that performs a 'single' read cycle of the input stream. | |
| virtual int | readInput (size_t &frameSize) noexcept |
| Helper method that executes the decoder, i.e. | |
| virtual void | sortCommandList () noexcept |
| Helper method. | |
Protected Attributes | |
| Cpl::Container::SList< Command > & | m_commands |
| Command list. | |
| Cpl::Text::Frame::StreamDecoder & | m_deframer |
| Raw input de-framer. | |
| Cpl::Text::Frame::StreamEncoder & | m_framer |
| Output framer handle. | |
| Cpl::System::Mutex & | m_outLock |
| Output lock. | |
| Security::Permission_T | m_userPermLevel |
| User's permission level. | |
| char | m_comment |
| Comment character. | |
| char | m_esc |
| Argument Escape character. | |
| char | m_del |
| Argument delimiter. | |
| char | m_quote |
| Argument quote character. | |
| char | m_term |
| Argument terminator character. | |
| bool | m_writeCommandPrompt |
| Set to true when 'command prompt' should be outputted. | |
| size_t | m_frameSize |
| Current frame size. | |
| bool | m_running |
| My run state. | |
| char | m_inputBuffer [OPTION_CPL_TSHELL_PROCESSOR_INPUT_SIZE+1] |
| Input Frame buffer. | |
| Cpl::Text::FString< OPTION_CPL_TSHELL_PROCESSOR_OUTPUT_SIZE > | m_outputBuffer |
| Buffer that is used to construct output messages. | |
| Cpl::Text::FString< OPTION_CPL_TSHELL_PROCESSOR_INPUT_SIZE > | m_tokenBuffer |
| Shared token work buffer. | |
| Cpl::Text::FString< OPTION_CPL_TSHELL_PROCESSOR_INPUT_SIZE > | m_tokenBuffer2 |
| Shared token work buffer. | |
| Cpl::TShell::Processor::Processor | ( | Cpl::Container::SList< Command > & | commands, |
| Cpl::Text::Frame::StreamDecoder & | deframer, | ||
| Cpl::Text::Frame::StreamEncoder & | framer, | ||
| Cpl::System::Mutex & | outputLock, | ||
| char | commentChar = '#', | ||
| char | argEscape = '`', | ||
| char | argDelimiter = ' ', | ||
| char | argQuote = '"', | ||
| char | argTerminator = '\n', | ||
| Security::Permission_T | initialPermissionLevel = Security::ePUBLIC ) |
Constructor.
| commands | Set of supported commands |
| deframer | Frame decoder used to identify individual command strings within the raw Input stream |
| framer | Frame encoder used to encapsulate the output of command in the Output stream. |
| outputLock | Mutex to be used for ensuring the atomic output of the commands. |
| commentChar | The comment character used to indicate that the input string is a comment and should not be executed. |
| argEscape | Escape character to be used when escaping double quote characters inside a quoted argument. |
| argDelimiter | The delimiter character used to separate the command verb and arguments. |
| argQuote | The quote character used to 'double quote' a argument string. |
| argTerminator | The command terminator character. |
| initialPermissionLevel | The initial minimum permission level that a user needs to issue command(s) |
|
protectedvirtualnoexcept |
Helper method that attempts to execute the content of the de-framed/decoded 'inputString'.
The method returns the result code of the execute command. If 'inputString' is not a valid command, then the appropriate error/result code is returned.
|
virtualnoexcept |
Implements Cpl::TShell::Context_.
|
protectednoexcept |
Helper method that performs a 'single' read cycle of the input stream.
Returns 0 if successful. Returns 1 if exiting. Returns -1 on error
|
virtualnoexcept |
Implements Cpl::TShell::Context_.
|
virtualnoexcept |
See Cpl::TShell::ProcessorApi.
Implements Cpl::TShell::ProcessorApi.
|
virtualnoexcept |
See Cpl::TShell::ProcessorApi.
Implements Cpl::TShell::ProcessorApi.
|
virtualnoexcept |
Implements Cpl::TShell::Context_.
|
virtualnoexcept |
See Cpl::TShell::ProcessorApi.
Implements Cpl::TShell::ProcessorApi.
|
virtualnoexcept |
See Cpl::TShell::ProcessorApi.
Implements Cpl::TShell::ProcessorApi.
|
virtualnoexcept |
Implements Cpl::TShell::Context_.
|
virtualnoexcept |
Implements Cpl::TShell::Context_.
|
virtualnoexcept |
Implements Cpl::TShell::Context_.
|
virtualnoexcept |
Implements Cpl::TShell::Context_.
|
protectednoexcept |
Helper method.
|
virtualnoexcept |
See Cpl::TShell::ProcessorApi.
Implements Cpl::TShell::ProcessorApi.
|
protectedvirtualnoexcept |
Helper method that executes the decoder, i.e.
logic to parse the incoming text. Returns 1 if a full/valid frame was found. Returns 0 if input frame is incomplete. Return -1 if an error occurred.
Reimplemented in Cpl::TShell::PolledProcessor.
|
virtualnoexcept |
See Cpl::TShell::ProcessorApi.
Implements Cpl::TShell::ProcessorApi.
|
virtualnoexcept |
Implements Cpl::TShell::Context_.
|
protectedvirtualnoexcept |
Helper method.
|
virtualnoexcept |
See Cpl::TShell::ProcessorApi.
Implements Cpl::TShell::ProcessorApi.
|
virtualnoexcept |
Implements Cpl::TShell::Context_.
|
virtualnoexcept |
Implements Cpl::TShell::Context_.
|
protected |
Command list.
|
protected |
Comment character.
|
protected |
Raw input de-framer.
|
protected |
Argument delimiter.
|
protected |
Argument Escape character.
|
protected |
Output framer handle.
|
protected |
Current frame size.
|
protected |
Input Frame buffer.
|
protected |
Output lock.
|
protected |
Buffer that is used to construct output messages.
|
protected |
Argument quote character.
|
protected |
My run state.
|
protected |
Argument terminator character.
|
protected |
Shared token work buffer.
|
protected |
Shared token work buffer.
|
protected |
User's permission level.
|
protected |
Set to true when 'command prompt' should be outputted.