1
0
mirror of https://github.com/NevermindZZT/letter-shell.git synced 2025-01-21 10:02:54 +08:00

修复 编译问题

This commit is contained in:
Letter 2021-05-24 15:51:59 +08:00
parent 8c87c8cd22
commit 663f792c60
5 changed files with 17 additions and 13 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
CMakeFiles CMakeFiles
cmake_install.cmake cmake_install.cmake
CMakeCache.txt CMakeCache.txt
demo/x86-gcc/Makefile demo/x86-gcc/Makefile
demo/x86-gcc/LetterShell

View File

@ -2,7 +2,7 @@
![version](https://img.shields.io/badge/version-3.1.0-brightgreen.svg) ![version](https://img.shields.io/badge/version-3.1.0-brightgreen.svg)
![standard](https://img.shields.io/badge/standard-c99-brightgreen.svg) ![standard](https://img.shields.io/badge/standard-c99-brightgreen.svg)
![build](https://img.shields.io/badge/build-2021.05.09-brightgreen.svg) ![build](https://img.shields.io/badge/build-2021.05.24-brightgreen.svg)
![license](https://img.shields.io/badge/license-MIT-brightgreen.svg) ![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)
一个功能强大的嵌入式shell 一个功能强大的嵌入式shell
@ -108,7 +108,7 @@
* *
* @return unsigned short 实际写入的字符数量 * @return unsigned short 实际写入的字符数量
*/ */
typedef unsigned short (*shellWrite)(const char *data, unsigned short len); typedef unsigned short (*shellWrite)(char *data, unsigned short len);
``` ```
3. 申请一片缓冲区 3. 申请一片缓冲区

View File

@ -139,7 +139,7 @@ typedef struct shell_command_cpp_key
const char shellDesc##_value[] = #_desc; \ const char shellDesc##_value[] = #_desc; \
extern "C" SHELL_USED const ShellCommandCppKey \ extern "C" SHELL_USED const ShellCommandCppKey \
shellKey##_value SHELL_SECTION("shellCommand") = \ shellKey##_value SHELL_SECTION("shellCommand") = \
{ \ { \
_attr|SHELL_CMD_TYPE(SHELL_TYPE_KEY), \ _attr|SHELL_CMD_TYPE(SHELL_TYPE_KEY), \
_value, \ _value, \
(void (*)(Shell *))_func, \ (void (*)(Shell *))_func, \
@ -152,3 +152,4 @@ typedef struct shell_command_cpp_key
#endif /**< __SHELL_CPP_H__ */ #endif /**< __SHELL_CPP_H__ */

View File

@ -258,7 +258,7 @@ Shell* shellGetCurrent(void)
* @param shell shell对象 * @param shell shell对象
* @param data * @param data
*/ */
static void shellWriteByte(Shell *shell, const char data) static void shellWriteByte(Shell *shell, char data)
{ {
shell->write(&data, 1); shell->write(&data, 1);
} }
@ -275,13 +275,13 @@ static void shellWriteByte(Shell *shell, const char data)
unsigned short shellWriteString(Shell *shell, const char *string) unsigned short shellWriteString(Shell *shell, const char *string)
{ {
unsigned short count = 0; unsigned short count = 0;
char *p = string; const char *p = string;
SHELL_ASSERT(shell->write, return 0); SHELL_ASSERT(shell->write, return 0);
while(*p++) while(*p++)
{ {
count ++; count ++;
} }
return shell->write(string, count); return shell->write((char *)string, count);
} }
@ -296,7 +296,7 @@ unsigned short shellWriteString(Shell *shell, const char *string)
static unsigned short shellWriteCommandDesc(Shell *shell, const char *string) static unsigned short shellWriteCommandDesc(Shell *shell, const char *string)
{ {
unsigned short count = 0; unsigned short count = 0;
char *p = string; const char *p = string;
SHELL_ASSERT(shell->write, return 0); SHELL_ASSERT(shell->write, return 0);
while (*p && *p != '\r' && *p != '\n') while (*p && *p != '\r' && *p != '\n')
{ {
@ -306,12 +306,12 @@ static unsigned short shellWriteCommandDesc(Shell *shell, const char *string)
if (count > 36) if (count > 36)
{ {
shell->write(string, 36); shell->write((char *)string, 36);
shell->write("...", 3); shell->write("...", 3);
} }
else else
{ {
shell->write(string, count); shell->write((char *)string, count);
} }
return count > 36 ? 36 : 39; return count > 36 ? 36 : 39;
} }
@ -389,7 +389,7 @@ void shellScan(Shell *shell, char *fmt, ...)
do { do {
if (shell->read(&buffer[index], 1) == 1) if (shell->read(&buffer[index], 1) == 1)
{ {
shell->write(buffer[index], 1); shell->write(&buffer[index], 1);
index++; index++;
} }
} while (buffer[index -1] != '\r' && buffer[index -1] != '\n' && index < SHELL_SCAN_BUFFER); } while (buffer[index -1] != '\r' && buffer[index -1] != '\n' && index < SHELL_SCAN_BUFFER);
@ -1757,7 +1757,7 @@ void shellWriteEndLine(Shell *shell, char *buffer, int len)
shellWriteString(shell, shell->parser.buffer); shellWriteString(shell, shell->parser.buffer);
for (short i = 0; i < shell->parser.length - shell->parser.cursor; i++) for (short i = 0; i < shell->parser.length - shell->parser.cursor; i++)
{ {
shell->write('\b', 1); shellWriteByte(shell, '\b');
} }
} }
} }
@ -1927,3 +1927,4 @@ SHELL_EXPORT_CMD(
SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_DISABLE_RETURN, SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_DISABLE_RETURN,
exec, shellExecute, execute function undefined); exec, shellExecute, execute function undefined);
#endif #endif

View File

@ -360,7 +360,7 @@ typedef struct shell_def
unsigned char tabFlag : 1; /**< tab标志 */ unsigned char tabFlag : 1; /**< tab标志 */
} status; } status;
signed short (*read)(char *, unsigned short); /**< shell读函数 */ signed short (*read)(char *, unsigned short); /**< shell读函数 */
signed short (*write)(const char *, unsigned short); /**< shell写函数 */ signed short (*write)(char *, unsigned short); /**< shell写函数 */
#if SHELL_USING_LOCK == 1 #if SHELL_USING_LOCK == 1
int (*lock)(struct shell_def *); /**< shell 加锁 */ int (*lock)(struct shell_def *); /**< shell 加锁 */
int (*unlock)(struct shell_def *); /**< shell 解锁 */ int (*unlock)(struct shell_def *); /**< shell 解锁 */
@ -461,3 +461,4 @@ void *shellCompanionGet(Shell *shell, int id);
#endif #endif