ChibiOS/RT Architecture - Reference Manual - Guides |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. 00003 00004 This file is part of ChibiOS/RT. 00005 00006 ChibiOS/RT is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 ChibiOS/RT is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 --- 00020 00021 A special exception to the GPL can be applied should you wish to distribute 00022 a combined work that includes ChibiOS/RT, without being obliged to provide 00023 the source code for any proprietary components. See the file exception.txt 00024 for full details of how and when the exception can be applied. 00025 */ 00026 00027 /** 00028 * @file shell.h 00029 * @brief Simple CLI shell header. 00030 * @addtogroup SHELL 00031 * @{ 00032 */ 00033 00034 #ifndef _SHELL_H_ 00035 #define _SHELL_H_ 00036 00037 /** 00038 * @brief Shell maximum input line length. 00039 */ 00040 #if !defined(SHELL_MAX_LINE_LENGTH) || defined(__DOXYGEN__) 00041 #define SHELL_MAX_LINE_LENGTH 64 00042 #endif 00043 00044 /** 00045 * @brief Shell maximum arguments per command. 00046 */ 00047 #if !defined(SHELL_MAX_ARGUMENTS) || defined(__DOXYGEN__) 00048 #define SHELL_MAX_ARGUMENTS 4 00049 #endif 00050 00051 /** 00052 * @brief Enforces the use of iprintf() on newlib. 00053 */ 00054 #if !defined(SHELL_USE_IPRINTF) || defined(__DOXYGEN__) 00055 #define SHELL_USE_IPRINTF TRUE 00056 #endif 00057 00058 /** 00059 * @brief Command handler function type. 00060 */ 00061 typedef void (*shellcmd_t)(BaseChannel *chp, int argc, char *argv[]); 00062 00063 /** 00064 * @brief Custom command entry type. 00065 */ 00066 typedef struct { 00067 const char *sc_name; /**< @brief Command name. */ 00068 shellcmd_t sc_function; /**< @brief Command function. */ 00069 } ShellCommand; 00070 00071 /** 00072 * @brief Shell descriptor type. 00073 */ 00074 typedef struct { 00075 BaseChannel *sc_channel; /**< @brief I/O channel associated 00076 to the shell. */ 00077 const ShellCommand *sc_commands; /**< @brief Shell extra commands 00078 table. */ 00079 } ShellConfig; 00080 00081 extern EventSource shell_terminated; 00082 00083 #ifdef __cplusplus 00084 extern "C" { 00085 #endif 00086 void shellInit(void); 00087 Thread *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio); 00088 void shellPrint(BaseChannel *chp, const char *msg); 00089 void shellPrintLine(BaseChannel *chp, const char *msg); 00090 bool_t shellGetLine(BaseChannel *chp, char *line, unsigned size); 00091 #ifdef __cplusplus 00092 } 00093 #endif 00094 00095 #endif /* _SHELL_H_ */ 00096 00097 /** @} */