给xcmd_print添加宏定义参数

This commit is contained in:
hqm 2021-09-22 22:02:20 +08:00
parent 496dcb9ea4
commit 7bb6f83c75
2 changed files with 10 additions and 4 deletions

View File

@ -1,7 +1,7 @@
/*
* @Author: your name
* @Date: 2021-09-17 23:03:06
* @LastEditTime: 2021-09-17 23:07:03
* @LastEditTime: 2021-09-22 21:59:50
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /xcmd/inc/xcmd_confg.h
@ -15,10 +15,16 @@ extern "C" {
#define VERSION "1.0.0"
#define XCMD_LINE_MAX_LENGTH (64) /* 命令行支持的最大字符数 */
#define XCMD_LINE_MAX_LENGTH (256) /* 命令行支持的最大字符数 */
#define XCMD_PRINT_BUF_MAX_LENGTH (128) /* xcmd_print缓存 */
#define XCMD_HISTORY_MAX_NUM (8) /* 支持的历史记录个数0为不支持 */
#define XCMD_PARAM_MAX_NUM (16) /* 支持输入的参数个数 */
#if XCMD_PRINT_BUF_MAX_LENGTH < (XCMD_LINE_MAX_LENGTH+32)
#undef XCMD_PRINT_BUF_MAX_LENGTH
#define XCMD_PRINT_BUF_MAX_LENGTH (XCMD_LINE_MAX_LENGTH+32) /* xcmd_print缓存 */
#endif
#ifdef __cplusplus
}
#endif

View File

@ -246,10 +246,10 @@ static void xcmd_parser(uint8_t byte)
void xcmd_print(const char *fmt, ...)
{
char ucstring[128] = {0};
char ucstring[XCMD_PRINT_BUF_MAX_LENGTH] = {0};
va_list arg;
va_start(arg, fmt);
vsnprintf(ucstring, 128, fmt, arg);
vsnprintf(ucstring, XCMD_PRINT_BUF_MAX_LENGTH, fmt, arg);
va_end(arg);
for(uint16_t i=0; ucstring[i]; i++)