还没有在STC单片机上使用,STC8估计够呛。它有一些全局变量会一直占有内存。
- typedef struct shell_def
- {
- struct
- {
- const struct shell_command *user; /**< 当前用户 */
- int activeTime; /**< shell激活时间 */
- char *path; /**< 当前shell路径 */
- #if SHELL_USING_COMPANION == 1
- struct shell_companion_object *companions; /**< 伴生对象 */
- #endif
- #if SHELL_KEEP_RETURN_VALUE == 1
- int retVal; /**< 返回值 */
- #endif
- } info;
- struct
- {
- unsigned short length; /**< 输入数据长度 */
- unsigned short cursor; /**< 当前光标位置 */
- char *buffer; /**< 输入缓冲 */
- char *param[SHELL_PARAMETER_MAX_NUMBER]; /**< 参数 */
- unsigned short bufferSize; /**< 输入缓冲大小 */
- unsigned short paramCount; /**< 参数数量 */
- int keyValue; /**< 输入按键键值 */
- } parser;
- #if SHELL_HISTORY_MAX_NUMBER > 0
- struct
- {
- char *item[SHELL_HISTORY_MAX_NUMBER]; /**< 历史记录 */
- unsigned short number; /**< 历史记录数 */
- unsigned short record; /**< 当前记录位置 */
- signed short offset; /**< 当前历史记录偏移 */
- } history;
- #endif /** SHELL_HISTORY_MAX_NUMBER > 0 */
- struct
- {
- void *base; /**< 命令表基址 */
- unsigned short count; /**< 命令数量 */
- } commandList;
- struct
- {
- unsigned char isChecked : 1; /**< 密码校验通过 */
- unsigned char isActive : 1; /**< 当前活动Shell */
- unsigned char tabFlag : 1; /**< tab标志 */
- } status;
- signed short (*read)(char *, unsigned short); /**< shell读函数 */
- signed short (*write)(char *, unsigned short); /**< shell写函数 */
- #if SHELL_USING_LOCK == 1
- int (*lock)(struct shell_def *); /**< shell 加锁 */
- int (*unlock)(struct shell_def *); /**< shell 解锁 */
- #endif
- } Shell;
复制代码
|