diff --git a/include/HDLog.h b/include/HDLog.h index ce359f7..881da37 100644 --- a/include/HDLog.h +++ b/include/HDLog.h @@ -4,6 +4,7 @@ #define __HD_NEW_LOG_H__ #include +#include // 使用宏开关管理日志 #ifndef LOG_CLOSE_OUT diff --git a/include/HDRPC.h b/include/HDRPC.h index ebb90b0..21c213e 100644 --- a/include/HDRPC.h +++ b/include/HDRPC.h @@ -70,6 +70,7 @@ enum eHDRPCException { kHDRPCNotException = 0x00, ///< 无异常 kHDRPCNotSupportFunction = 0x01, ///< 对应功能不支持 kHDRPCArgsTypeNotMatch = 0x02, ///< 参数类型不匹配 + kHDRPCNotReply = 0x03, ///< 无回复 }; @@ -181,7 +182,8 @@ void HDRPCSetExceptionNotSkip(HDRPCSession *session, uint8_t enable); */ #define HDRPCCreate(_name, _len) HDRPCArgs _args##_name[_len + 1]; HDRPCSession _session##_name; HDRPCInitSession(&_session##_name, _args##_name, _len + 1); HDRPCSession *_name = &_session##_name -#define HDRPCReset(_name, _len) HDRPCInitSession(&_session##_name, _args##_name, _len + 1) +#define HDRPCResetN(_name, _len) HDRPCInitSession(&_session##_name, _args##_name, _len + 1) +#define HDRPCReset(_name) HDRPCInitSession(&_session##_name, _args##_name, (sizeof(_args##_name) / sizeof(_args##_name[0]))) /** * @brief 用于辅助宏添加数据到session diff --git a/include/HProtocolBind.h b/include/HProtocolBind.h index 3628603..ff1bc0f 100644 --- a/include/HProtocolBind.h +++ b/include/HProtocolBind.h @@ -32,7 +32,7 @@ typedef int16_t HProtocolBind_t; typedef uint8_t HProtocolBindId_t; ///< 功能码 -typedef uint16_t HProtocolBindFunc_t; +typedef uint32_t HProtocolBindFunc_t; ///< 协议回调 typedef void (*HProtocolBindCallback)(HProtocolBind_t index, uint8_t* data, uint16_t len); diff --git a/include/HShellLex.h b/include/HShellLex.h index 87598c0..a6d59e2 100644 --- a/include/HShellLex.h +++ b/include/HShellLex.h @@ -142,7 +142,7 @@ void HSHellUnregister(int16_t index); * @param strLen 命令行数据长度 **/ void HShellAddCmdData(uint8_t data); -void HSHellAddCmdDatas(const uint8_t *data, int len); +void HSHellAddCmdDatas(const void *data, int len); /** * @brief 处理命令行数据, 因添加数据在中断, 执行需在非中断执行 diff --git a/src/HDProtocolServer.c b/src/HDProtocolServer.c index 691cd8b..fbd1aea 100644 --- a/src/HDProtocolServer.c +++ b/src/HDProtocolServer.c @@ -373,6 +373,11 @@ void HDProtocolRun() continue; } + // 正在解析使用的协议触发的协议运转, 不要继续重叠处理 + if (i == sInfo.useIndex) { + continue; + } + if (i >= OCCUPIED_MAX) { LogE("index[%d] is out of range[%d]", i, OCCUPIED_MAX); break; diff --git a/src/HShellLex.c b/src/HShellLex.c index be1391a..215ef5d 100644 --- a/src/HShellLex.c +++ b/src/HShellLex.c @@ -461,13 +461,14 @@ void HShellAddCmdData(uint8_t data) { AddCmdData(data); } -void HSHellAddCmdDatas(const uint8_t *data, int len) { - if (shellInfo_.run) { +void HSHellAddCmdDatas(const void *data, int len) { + if (shellInfo_.run || data == NULL) { return ; } + const uint8_t *d = (const uint8_t *)data; for (int i = 0; i < len; ++i) { - AddCmdData(data[i]); + AddCmdData(d[i]); } }