Files
2025-05-06 13:07:01 +00:00

910 lines
40 KiB
C

/* ###################################################################
** This component module is generated by Processor Expert. Do not modify it.
** Filename : McuShell.h
** Project : FRDM-K64F_Generator
** Processor : MK64FN1M0VLL12
** Component : Shell
** Version : Component 01.115, Driver 01.00, CPU db: 3.00.000
** Compiler : GNU C Compiler
** Date/Time : 2025-01-16, 10:11, # CodeGen: 850
** Abstract :
** Module implementing a command line shell.
** Settings :
** Component name : McuShell
** Echo : no
** Prompt : "CMD> "
** Project Name : My Project Name
** Silent Mode Prefix : #
** Buffer Size : 48
** Blocking Send : Enabled
** Wait : McuWait
** Timeout (ms) : 20
** Wait Time (ms) : 5
** RTOS Wait : yes
** Status Colon Pos : 13
** Help Semicolon Pos : 26
** Multi Command : Disabled
** Utility : McuUtility
** Default Serial : Disabled
** Semaphore : no
** Critical Section : McuCriticalSection
** History : no
** Kinetis SDK : McuLib
** Contents :
** PrintPrompt - void McuShell_PrintPrompt(McuShell_ConstStdIOType *io);
** SendNum8u - void McuShell_SendNum8u(uint8_t val, McuShell_StdIO_OutErr_FctType io);
** SendNum8s - void McuShell_SendNum8s(int8_t val, McuShell_StdIO_OutErr_FctType io);
** SendNum16u - void McuShell_SendNum16u(uint16_t val, McuShell_StdIO_OutErr_FctType io);
** SendNum16s - void McuShell_SendNum16s(int16_t val, McuShell_StdIO_OutErr_FctType io);
** SendNum32u - void McuShell_SendNum32u(uint32_t val, McuShell_StdIO_OutErr_FctType io);
** SendNum32s - void McuShell_SendNum32s(int32_t val, McuShell_StdIO_OutErr_FctType io);
** SendCh - void McuShell_SendCh(uint8_t ch, McuShell_StdIO_OutErr_FctType io);
** SendStr - void McuShell_SendStr(const uint8_t *str, McuShell_StdIO_OutErr_FctType io);
** PrintMemory - uint8_t McuShell_PrintMemory(void *hndl, uint32_t startAddr, uint32_t...
** printfIO - unsigned McuShell_printfIO(McuShell_ConstStdIOType *io, const char *fmt, ...);
** printf - unsigned McuShell_printf(const char *fmt, ...);
** SendData - void McuShell_SendData(const uint8_t *data, uint16_t dataSize,...
** PrintStatus - uint8_t McuShell_PrintStatus(McuShell_ConstStdIOType *io);
** ParseCommand - uint8_t McuShell_ParseCommand(const uint8_t *cmd, bool *handled,...
** IsHistoryCharacter - bool McuShell_IsHistoryCharacter(uint8_t ch, uint8_t *cmdBuf, size_t...
** ProcessConsoleInput - int McuShell_ProcessConsoleInput(char *buf, size_t bufSize);
** ReadLine - bool McuShell_ReadLine(uint8_t *bufStart, uint8_t *buf, size_t bufSize,...
** PrintCommandFailed - void McuShell_PrintCommandFailed(const uint8_t *cmd, McuShell_ConstStdIOType...
** IterateTable - uint8_t McuShell_IterateTable(const uint8_t *cmd, bool *handled,...
** SetStdio - uint8_t McuShell_SetStdio(McuShell_ConstStdIOTypePtr stdio);
** GetStdio - McuShell_ConstStdIOTypePtr McuShell_GetStdio(void);
** RequestSerial - void McuShell_RequestSerial(void);
** ReleaseSerial - void McuShell_ReleaseSerial(void);
** ReadAndParseWithCommandTableExt - uint8_t McuShell_ReadAndParseWithCommandTableExt(uint8_t *cmdBuf, size_t...
** ReadCommandLine - uint8_t McuShell_ReadCommandLine(uint8_t *cmdBuf, size_t cmdBufSize,...
** ReadAndParseWithCommandTable - uint8_t McuShell_ReadAndParseWithCommandTable(uint8_t *cmdBuf, size_t...
** ParseWithCommandTableExt - uint8_t McuShell_ParseWithCommandTableExt(const uint8_t *cmd,...
** ParseWithCommandTable - uint8_t McuShell_ParseWithCommandTable(const uint8_t *cmd,...
** GetSemaphore - void* McuShell_GetSemaphore(void);
** SendStatusStr - void McuShell_SendStatusStr(const uint8_t *strItem, const uint8_t *strStatus,...
** SendHelpStr - void McuShell_SendHelpStr(const uint8_t *strCmd, const uint8_t *strHelp,...
** ReadChar - void McuShell_ReadChar(uint8_t *c);
** SendChar - void McuShell_SendChar(uint8_t ch);
** KeyPressed - bool McuShell_KeyPressed(void);
** SendCharFct - void McuShell_SendCharFct(uint8_t ch, uint8_t (*fct)(uint8_t ch));
** Init - void McuShell_Init(void);
** Deinit - void McuShell_Deinit(void);
**
** * Copyright (c) 2014-2025, Erich Styger
** * Web: https://mcuoneclipse.com
** * SourceForge: https://sourceforge.net/projects/mcuoneclipse
** * Git: https://github.com/ErichStyger/McuOnEclipse_PEx
** * All rights reserved.
** *
** * Redistribution and use in source and binary forms, with or without modification,
** * are permitted provided that the following conditions are met:
** *
** * - Redistributions of source code must retain the above copyright notice, this list
** * of conditions and the following disclaimer.
** *
** * - Redistributions in binary form must reproduce the above copyright notice, this
** * list of conditions and the following disclaimer in the documentation and/or
** * other materials provided with the distribution.
** *
** * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
** * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
** * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
** ###################################################################*/
/*!
** @file McuShell.h
** @version 01.00
** @brief
** Module implementing a command line shell.
*/
/*!
** @addtogroup McuShell_module McuShell module documentation
** @{
*/
#ifndef __McuShell_H
#define __McuShell_H
/* MODULE McuShell. */
#include "McuLib.h" /* SDK and API used */
#include "McuShellconfig.h" /* configuration */
#include <stdint.h>
#include <stdbool.h>
#ifndef __BWUserType_McuShell_StdIO_OutErr_FctType
#define __BWUserType_McuShell_StdIO_OutErr_FctType
typedef void (*McuShell_StdIO_OutErr_FctType)(uint8_t); /* Callback for an output or error I/O function */
#endif
#ifndef __BWUserType_McuShell_StdIO_In_FctType
#define __BWUserType_McuShell_StdIO_In_FctType
typedef void (*McuShell_StdIO_In_FctType)(uint8_t *); /* Callback for an I/O input function. */
#endif
#ifndef __BWUserType_McuShell_StdIO_KeyPressed_FctType
#define __BWUserType_McuShell_StdIO_KeyPressed_FctType
typedef bool (*McuShell_StdIO_KeyPressed_FctType)(void); /* Callback which returns true if a key has been pressed */
#endif
#ifndef __BWUserType_McuShell_StdIOType
#define __BWUserType_McuShell_StdIOType
typedef struct { /* Record containing input, output and error callback (stdin, stdout, stderr). */
McuShell_StdIO_In_FctType stdIn; /* standard input */
McuShell_StdIO_OutErr_FctType stdOut; /* standard output */
McuShell_StdIO_OutErr_FctType stdErr; /* standard error */
McuShell_StdIO_KeyPressed_FctType keyPressed; /* key pressed callback */
#if McuShell_CONFIG_ECHO_ENABLED
bool echoEnabled; /* true if I/O shall echo characters */
#endif
} McuShell_StdIOType;
#endif
#ifndef __BWUserType_McuShell_ConstStdIOType
#define __BWUserType_McuShell_ConstStdIOType
typedef const McuShell_StdIOType McuShell_ConstStdIOType; /* constant StdIOType */
#endif
#ifndef __BWUserType_McuShell_ParseCommandCallback
#define __BWUserType_McuShell_ParseCommandCallback
typedef uint8_t (*McuShell_ParseCommandCallback)(const uint8_t *cmd, bool *handled, const McuShell_StdIOType *io); /* Callback for parsing a shell command */
#endif
#ifndef __BWUserType_McuShell_ConstStdIOTypePtr
#define __BWUserType_McuShell_ConstStdIOTypePtr
typedef const McuShell_ConstStdIOType *McuShell_ConstStdIOTypePtr; /* Pointer to constant standard I/O descriptor */
#endif
#ifndef __BWUserType_McuShell_ConstParseCommandCallback
#define __BWUserType_McuShell_ConstParseCommandCallback
typedef const McuShell_ParseCommandCallback McuShell_ConstParseCommandCallback; /* Callback for parsing a shell command */
#endif
#define McuShell_DEFAULT_SHELL_BUFFER_SIZE McuShell_CONFIG_DEFAULT_SHELL_BUFFER_SIZE /* default buffer size for shell command parsing */
/* Include inherited components */
/* other includes needed */
#include <stddef.h> /* for size_t */
/* VTxxx control and color codes which can be used in terminals supporting color. See https://en.wikipedia.org/wiki/ANSI_escape_code */
/* general control */
#define McuShell_ANSI_CONTROL_RESET "\033[0m" /* reset to defaults */
#define McuShell_ANSI_CONTROL_CLEAR "\033[2J" /* clear terminal */
/* text colors: */
#define McuShell_ANSI_COLOR_TEXT_BLACK "\033[2;30m"
#define McuShell_ANSI_COLOR_TEXT_RED "\033[2;31m"
#define McuShell_ANSI_COLOR_TEXT_GREEN "\033[2;32m"
#define McuShell_ANSI_COLOR_TEXT_YELLOW "\033[2;33m"
#define McuShell_ANSI_COLOR_TEXT_BLUE "\033[2;34m"
#define McuShell_ANSI_COLOR_TEXT_MAGENTA "\033[2;35m"
#define McuShell_ANSI_COLOR_TEXT_CYAN "\033[2;36m"
#define McuShell_ANSI_COLOR_TEXT_WHITE "\033[2;37m"
#define McuShell_ANSI_COLOR_TEXT_BRIGHT_BLACK "\033[1;30m"
#define McuShell_ANSI_COLOR_TEXT_BRIGHT_RED "\033[1;31m"
#define McuShell_ANSI_COLOR_TEXT_BRIGHT_GREEN "\033[1;32m"
#define McuShell_ANSI_COLOR_TEXT_BRIGHT_YELLOW "\033[1;33m"
#define McuShell_ANSI_COLOR_TEXT_BRIGHT_BLUE "\033[1;34m"
#define McuShell_ANSI_COLOR_TEXT_BRIGHT_MAGENTA "\033[1;35m"
#define McuShell_ANSI_COLOR_TEXT_BRIGHT_CYAN "\033[1;36m"
#define McuShell_ANSI_COLOR_TEXT_BRIGHT_WHITE "\033[1;37m"
/* text background colors */
#define McuShell_ANSI_COLOR_BG_BLACK "\033[24;40m"
#define McuShell_ANSI_COLOR_BG_RED "\033[24;41m"
#define McuShell_ANSI_COLOR_BG_GREEN "\033[24;42m"
#define McuShell_ANSI_COLOR_BG_YELLOW "\033[24;43m"
#define McuShell_ANSI_COLOR_BG_BLUE "\033[24;44m"
#define McuShell_ANSI_COLOR_BG_MAGENTA "\033[24;45m"
#define McuShell_ANSI_COLOR_BG_CYAN "\033[24;46m"
#define McuShell_ANSI_COLOR_BG_WHITE "\033[24;47m"
#define McuShell_ANSI_COLOR_BG_BRIGHT_BLACK "\033[4;40m"
#define McuShell_ANSI_COLOR_BG_BRIGHT_RED "\033[4;41m"
#define McuShell_ANSI_COLOR_BG_BRIGHT_GREEN "\033[4;42m"
#define McuShell_ANSI_COLOR_BG_BRIGHT_YELLOW "\033[4;43m"
#define McuShell_ANSI_COLOR_BRIGHT_BLUE "\033[4;44m"
#define McuShell_ANSI_COLOR_BRIGHT_MAGENTA "\033[4;45m"
#define McuShell_ANSI_COLOR_BRIGHT_CYAN "\033[4;46m"
#define McuShell_ANSI_COLOR_BRIGHT_WHITE "\033[4;47m"
/* settings for silent prefix char */
#define McuShell_NO_SILENT_PREFIX_CHAR ' ' /* used for no silent prefix char */
#define McuShell_SILENT_PREFIX_CHAR_ENABLED (McuShell_CONFIG_SILENT_PREFIX_CHAR != McuShell_NO_SILENT_PREFIX_CHAR)
#define McuShell_DEFAULT_SERIAL McuShell_CONFIG_DEFAULT_SERIAL /* If set to 1, then the shell implements its own StdIO which is returned by McuShell_GetStdio(); */
extern uint8_t McuShell_DefaultShellBuffer[McuShell_DEFAULT_SHELL_BUFFER_SIZE]; /* default buffer which can be used by the application */
#if McuShell_DEFAULT_SERIAL
extern McuShell_ConstStdIOType McuShell_stdio; /* default standard I/O */
#endif
#define McuShell_DASH_LINE "--------------------------------------------------------------"
/* predefined commands */
#define McuShell_CMD_HELP "help"
#define McuShell_CMD_STATUS "status"
#ifdef __cplusplus
extern "C" {
#endif
void McuShell_SendStr(const uint8_t *str, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendStr (component Shell)
**
** Description :
** Prints a string using an I/O function
** Parameters :
** NAME - DESCRIPTION
** * str - Pointer to string (zero terminated) to be
** printed.
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
uint8_t McuShell_ParseCommand(const uint8_t *cmd, bool *handled, McuShell_ConstStdIOType *io);
/*
** ===================================================================
** Method : ParseCommand (component Shell)
**
** Description :
** Parses a shell command. Use 'help' to get a list of
** supported commands.
** Parameters :
** NAME - DESCRIPTION
** * cmd - Pointer to command string
** * handled - Pointer to variable to indicate if
** the command has been handled. The caller
** passes this variable to the command scanner
** to find out if the passed command has been
** handled. The variable is initialized by the
** caller.
** * io - Pointer to I/O callbacks
** Returns :
** --- - Error code
** ===================================================================
*/
void McuShell_SendNum32s(int32_t val, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendNum32s (component Shell)
**
** Description :
** Sends a 32bit signed number to the given I/O
** Parameters :
** NAME - DESCRIPTION
** val - number to print
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
void McuShell_SendNum16s(int16_t val, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendNum16s (component Shell)
**
** Description :
** Sends a 16bit signed number to the given I/O
** Parameters :
** NAME - DESCRIPTION
** val - number to print
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
void McuShell_PrintPrompt(McuShell_ConstStdIOType *io);
/*
** ===================================================================
** Method : PrintPrompt (component Shell)
**
** Description :
** Prints the prompt to the stdOut channel
** Parameters :
** NAME - DESCRIPTION
** * io - Pointer to IO to be used
** Returns : Nothing
** ===================================================================
*/
bool McuShell_ReadLine(uint8_t *bufStart, uint8_t *buf, size_t bufSize, McuShell_ConstStdIOType *io);
/*
** ===================================================================
** Method : ReadLine (component Shell)
**
** Description :
** Reads a line from stdIn and returns TRUE if we have a line,
** FALSE otherwise.
** Parameters :
** NAME - DESCRIPTION
** * bufStart - Pointer to start of buffer
** * buf - Pointer to buffer where to read in the
** information
** bufSize - size of buffer
** * io - Pointer to I/O callbacks
** Returns :
** --- - TRUE if something has been read, FALSE
** otherwise
** ===================================================================
*/
uint8_t McuShell_PrintStatus(McuShell_ConstStdIOType *io);
/*
** ===================================================================
** Method : PrintStatus (component Shell)
**
** Description :
** Prints various available system status information
** Parameters :
** NAME - DESCRIPTION
** * io - Pointer to I/O callbacks
** Returns :
** --- - Error code
** ===================================================================
*/
void McuShell_PrintCommandFailed(const uint8_t *cmd, McuShell_ConstStdIOType *io);
/*
** ===================================================================
** Method : PrintCommandFailed (component Shell)
**
** Description :
** Prints a standard message for failed or unknown commands
** Parameters :
** NAME - DESCRIPTION
** * cmd - Pointer to command which was failing
** * io - Pointer to I/O callbacks
** Returns : Nothing
** ===================================================================
*/
uint8_t McuShell_ParseWithCommandTable(const uint8_t *cmd, McuShell_ConstStdIOType *io, McuShell_ConstParseCommandCallback *parseCallback);
/*
** ===================================================================
** Method : ParseWithCommandTable (component Shell)
**
** Description :
** Parses a shell command. It handles first the internal
** commands and will call the provided callback.
** Parameters :
** NAME - DESCRIPTION
** * cmd - Pointer to command string
** * io - Pointer to I/O callbacks
** * parseCallback - Pointer to callback
** which will be called to parse commands in
** the user application, or NULL if not used.
** Returns :
** --- - Error code
** ===================================================================
*/
McuShell_ConstStdIOTypePtr McuShell_GetStdio(void);
/*
** ===================================================================
** Method : GetStdio (component Shell)
**
** Description :
** Returns the default stdio channel. This method is only
** available if a shell is enabled in the component properties.
** Parameters : None
** Returns :
** --- - Pointer to the stdio descriptor
** ===================================================================
*/
void McuShell_SendNum32u(uint32_t val, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendNum32u (component Shell)
**
** Description :
** Sends a 32bit unsigned number to the given I/O
** Parameters :
** NAME - DESCRIPTION
** val - number to print
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
void McuShell_SendNum16u(uint16_t val, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendNum16u (component Shell)
**
** Description :
** Sends a 16bit unsigned number to the given I/O
** Parameters :
** NAME - DESCRIPTION
** val - number to print
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
void McuShell_SendNum8u(uint8_t val, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendNum8u (component Shell)
**
** Description :
** Sends an 8bit unsigned number to the given I/O
** Parameters :
** NAME - DESCRIPTION
** val - number to print
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
void McuShell_SendNum8s(int8_t val, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendNum8s (component Shell)
**
** Description :
** Sends an 8bit signed number to the given I/O
** Parameters :
** NAME - DESCRIPTION
** val - number to print
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
void McuShell_Init(void);
/*
** ===================================================================
** Method : Init (component Shell)
**
** Description :
** Initializes the module, especially creates the mutex
** semaphore if an RTOS is used.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
void McuShell_RequestSerial(void);
/*
** ===================================================================
** Method : RequestSerial (component Shell)
**
** Description :
** Used to get mutual access to the shell console. Only has an
** effect if using an RTOS with semaphore for the console
** access.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
void McuShell_ReleaseSerial(void);
/*
** ===================================================================
** Method : ReleaseSerial (component Shell)
**
** Description :
** Used to release mutual access to the shell console. Only has
** an effect if using an RTOS with semaphore for the console
** access.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
void McuShell_SendHelpStr(const uint8_t *strCmd, const uint8_t *strHelp, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendHelpStr (component Shell)
**
** Description :
** Prints a string using an I/O function, formated for the
** 'help' command
** Parameters :
** NAME - DESCRIPTION
** * strCmd - Pointer to string of the command
** * strHelp - Pointer to help text string
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
void McuShell_SendStatusStr(const uint8_t *strItem, const uint8_t *strStatus, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendStatusStr (component Shell)
**
** Description :
** Prints a status string using an I/O function, formated for
** the 'status' command
** Parameters :
** NAME - DESCRIPTION
** * strItem - Pointer to string of the command
** * strStatus - Pointer to help text string
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
void McuShell_ReadChar(uint8_t *c);
/*
** ===================================================================
** Method : ReadChar (component Shell)
**
** Description :
** Reads a character (blocking)
** Parameters :
** NAME - DESCRIPTION
** * c - Pointer to character to be used to store the
** result
** Returns : Nothing
** ===================================================================
*/
void McuShell_SendChar(uint8_t ch);
/*
** ===================================================================
** Method : SendChar (component Shell)
**
** Description :
** Sends a character (blocking)
** Parameters :
** NAME - DESCRIPTION
** ch - character to be sent
** Returns : Nothing
** ===================================================================
*/
bool McuShell_KeyPressed(void);
/*
** ===================================================================
** Method : KeyPressed (component Shell)
**
** Description :
** Checks if a key has been pressed (a character is present in
** the input buffer)
** Parameters : None
** Returns :
** --- - Error code
** ===================================================================
*/
void McuShell_Deinit(void);
/*
** ===================================================================
** Method : Deinit (component Shell)
**
** Description :
** De-Initializes the module, especially frees the mutex
** semaphore if an RTOS is used.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
void* McuShell_GetSemaphore(void);
/*
** ===================================================================
** Method : GetSemaphore (component Shell)
**
** Description :
** Return the semaphore of the shell.
** Parameters : None
** Returns :
** --- - semaphore, or NULL if not used or not
** allocated.
** ===================================================================
*/
uint8_t McuShell_ReadAndParseWithCommandTable(uint8_t *cmdBuf, size_t cmdBufSize, McuShell_ConstStdIOType *io, McuShell_ConstParseCommandCallback *parseCallback);
/*
** ===================================================================
** Method : ReadAndParseWithCommandTable (component Shell)
**
** Description :
** Reads characters from the default input channel and appends
** it to the buffer. Once a new line has been detected, the
** line will be parsed using the handlers in the table.
** Parameters :
** NAME - DESCRIPTION
** * cmdBuf - Pointer to buffer provided by the
** caller where to store the command to read
** in. Characters will be appended, so make
** sure string buffer is initialized with a
** zero byte at the beginning.
** cmdBufSize - Size of buffer
** * io - Pointer to I/O channels to be used
** * parseCallback - Pointer to callback
** table provided by the user application to
** parse commands. The table has a NULL
** sentinel.
** Returns :
** --- - Error code
** ===================================================================
*/
uint8_t McuShell_IterateTable(const uint8_t *cmd, bool *handled, McuShell_ConstStdIOType *io, McuShell_ConstParseCommandCallback *parserTable);
/*
** ===================================================================
** Method : IterateTable (component Shell)
**
** Description :
** Parses a shell command. It handles first the internal
** commands and will call the provided callback.
** Parameters :
** NAME - DESCRIPTION
** * cmd - Pointer to command string
** * handled - Pointer to boolean which is set to
** TRUE if a command parser has handled the
** command.
** * io - Pointer to I/O callbacks
** * parserTable - Pointer to callback which
** will be called to parse commands in the
** user application, or NULL if not used.
** Returns :
** --- - Error code
** ===================================================================
*/
uint8_t McuShell_SetStdio(McuShell_ConstStdIOTypePtr stdio);
/*
** ===================================================================
** Method : SetStdio (component Shell)
**
** Description :
** Sets an StdIO structure which is returned by GetStdio()
** Parameters :
** NAME - DESCRIPTION
** stdio - New stdio structure to be used.
** Returns :
** --- - Error code
** ===================================================================
*/
void McuShell_SendData(const uint8_t *data, uint16_t dataSize, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendData (component Shell)
**
** Description :
** Sends data using an I/O function. Unlike SendStr(), with
** this method it is possible to send binary data, including
** zero bytes.
** Parameters :
** NAME - DESCRIPTION
** * data - Pointer to data to be sent
** dataSize - Number of bytes to be sent.
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
bool McuShell_IsHistoryCharacter(uint8_t ch, uint8_t *cmdBuf, size_t cmdBufIdx, bool *isPrev);
/*
** ===================================================================
** Method : IsHistoryCharacter (component Shell)
**
** Description :
** Returns TRUE if character is a history character
** Parameters :
** NAME - DESCRIPTION
** ch - current command character
** * cmdBuf - Pointer to command line buffer read
** so far
** cmdBufIdx - Index of character into cmdBuf
** * isPrev - Pointer to return value, if it is
** 'previous' history or not
** Returns :
** --- - TRUE if it is an accepted history character
** ===================================================================
*/
void McuShell_SendCh(uint8_t ch, McuShell_StdIO_OutErr_FctType io);
/*
** ===================================================================
** Method : SendCh (component Shell)
**
** Description :
** Prints a character using an I/O function
** Parameters :
** NAME - DESCRIPTION
** ch - Character to send
** io - I/O callbacks to be used for printing.
** Returns : Nothing
** ===================================================================
*/
unsigned McuShell_printf(const char *fmt, ...);
/*
** ===================================================================
** Method : printf (component Shell)
**
** Description :
** Printf() style function using XFormat component, using the
** shell default I/O handler.
** Parameters :
** NAME - DESCRIPTION
** fmt - printf style format string
** Returns :
** --- - number of characters written
** ===================================================================
*/
void McuShell_printfPutChar(void *arg, char c);
/*
** ===================================================================
** Method : McuShell_printfPutChar (component Shell)
**
** Description :
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
unsigned McuShell_printfIO(McuShell_ConstStdIOType *io, const char *fmt, ...);
/*
** ===================================================================
** Method : printfIO (component Shell)
**
** Description :
** Printf() style function using XFormat component, using a
** custom I/O handler.
** Parameters :
** NAME - DESCRIPTION
** * io - Pointer to
** fmt - printf style format string
** Returns :
** --- - number of characters written
** ===================================================================
*/
void McuShell_SendCharFct(uint8_t ch, uint8_t (*fct)(uint8_t ch));
/*
** ===================================================================
** Method : SendCharFct (component Shell)
**
** Description :
** Method to send a character using a standard I/O handle.
** Parameters :
** NAME - DESCRIPTION
** ch - character to be sent
** * fct - Function pointer to output function: takes
** a byte to write and returns error code.
** Returns : Nothing
** ===================================================================
*/
uint8_t McuShell_PrintMemory(void *hndl, uint32_t startAddr, uint32_t endAddr, uint8_t addrSize, uint8_t bytesPerLine, uint8_t (*readfp)(void *, uint32_t, uint8_t*, size_t), McuShell_ConstStdIOType *io);
/*
** ===================================================================
** Method : PrintMemory (component Shell)
**
** Description :
** Prints a chunk of memory bytes in a formatted way.
** Parameters :
** NAME - DESCRIPTION
** * hndl - Pointer to
** startAddr - Memory start address
** endAddr - Memory end address
** addrSize - Number of bytes for the address
** (1, 2, 3 or 4)
** bytesPerLine - Number of bytes per line
** readfp - Function pointer to read the memory.
** Returns error code, uses a device handle,
** 32bit address with a pointer to a buffer
** and a buffer size.
** * io - Pointer to I/O to be used
** Returns :
** --- - Error code
** ===================================================================
*/
uint8_t McuShell_ReadAndParseWithCommandTableExt(uint8_t *cmdBuf, size_t cmdBufSize, McuShell_ConstStdIOType *io, McuShell_ConstParseCommandCallback *parseCallback, bool silent);
/*
** ===================================================================
** Method : ReadAndParseWithCommandTableExt (component Shell)
**
** Description :
** Reads characters from the default input channel and appends
** it to the buffer. Once a new line has been detected, the
** line will be parsed using the handlers in the table.
** Parameters :
** NAME - DESCRIPTION
** * cmdBuf - Pointer to buffer provided by the
** caller where to store the command to read
** in. Characters will be appended, so make
** sure string buffer is initialized with a
** zero byte at the beginning.
** cmdBufSize - Size of buffer
** * io - Pointer to I/O channels to be used
** * parseCallback - Pointer to callback
** table provided by the user application to
** parse commands. The table has a NULL
** sentinel.
** silent - If handling shall be silent, i.e. no
** command prompt printed
** Returns :
** --- - Error code
** ===================================================================
*/
uint8_t McuShell_ParseWithCommandTableExt(const uint8_t *cmd, McuShell_ConstStdIOType *io, McuShell_ConstParseCommandCallback *parseCallback, bool silent);
/*
** ===================================================================
** Method : ParseWithCommandTableExt (component Shell)
**
** Description :
** Parses a shell command. It handles first the internal
** commands and will call the provided callback.
** Parameters :
** NAME - DESCRIPTION
** * cmd - Pointer to command string
** * io - Pointer to I/O callbacks
** * parseCallback - Pointer to callback
** which will be called to parse commands in
** the user application, or NULL if not used.
** silent - If handling shall be silent, i.e. no
** command prompt printed
** Returns :
** --- - Error code
** ===================================================================
*/
uint8_t McuShell_ReadCommandLine(uint8_t *cmdBuf, size_t cmdBufSize, McuShell_ConstStdIOType *io);
/*
** ===================================================================
** Method : ReadCommandLine (component Shell)
**
** Description :
** Similar to ReadAndParseWithCommandTableExt, but does not
** call the parser. Reads characters from the default input
** channel and appends it to the buffer. Once a new line has
** been detected, it removes it and returns ERR_OK
** Parameters :
** NAME - DESCRIPTION
** * cmdBuf - Pointer to buffer provided by the
** caller where to store the command to read
** in. Characters will be appended, so make
** sure string buffer is initialized with a
** zero byte at the beginning.
** cmdBufSize - Size of buffer
** * io - Pointer to I/O channels to be used
** Returns :
** --- - Error code, ERR_OK if a complete line has
** been detected
** ===================================================================
*/
int McuShell_ProcessConsoleInput(char *buf, size_t bufSize);
/*
** ===================================================================
** Method : ProcessConsoleInput (component Shell)
**
** Description :
** Processes a string received from a console which can include
** backspace characters.
** Parameters :
** NAME - DESCRIPTION
** * buf - Pointer to character buffer
** bufSize - Size of buffer
** Returns :
** --- - Number of characters in the buffer
** ===================================================================
*/
/* END McuShell. */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
/* ifndef __McuShell_H */
/*!
** @}
*/