1. 完善RPC

2. 修复协议调度的重叠问题
This commit is contained in:
coffee 2025-11-25 11:17:01 +08:00
parent 7cbcef238e
commit 507c72cb98
6 changed files with 15 additions and 6 deletions

View File

@ -4,6 +4,7 @@
#define __HD_NEW_LOG_H__
#include <stdint.h>
#include <string.h>
// 使用宏开关管理日志
#ifndef LOG_CLOSE_OUT

View File

@ -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

View File

@ -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);

View File

@ -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 , ,

View File

@ -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;

View File

@ -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]);
}
}