1. 完善RPC
2. 修复协议调度的重叠问题
This commit is contained in:
parent
7cbcef238e
commit
507c72cb98
@ -4,6 +4,7 @@
|
|||||||
#define __HD_NEW_LOG_H__
|
#define __HD_NEW_LOG_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
// 使用宏开关管理日志
|
// 使用宏开关管理日志
|
||||||
#ifndef LOG_CLOSE_OUT
|
#ifndef LOG_CLOSE_OUT
|
||||||
|
|||||||
@ -70,6 +70,7 @@ enum eHDRPCException {
|
|||||||
kHDRPCNotException = 0x00, ///< 无异常
|
kHDRPCNotException = 0x00, ///< 无异常
|
||||||
kHDRPCNotSupportFunction = 0x01, ///< 对应功能不支持
|
kHDRPCNotSupportFunction = 0x01, ///< 对应功能不支持
|
||||||
kHDRPCArgsTypeNotMatch = 0x02, ///< 参数类型不匹配
|
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 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
|
* @brief 用于辅助宏添加数据到session
|
||||||
|
|||||||
@ -32,7 +32,7 @@ typedef int16_t HProtocolBind_t;
|
|||||||
typedef uint8_t HProtocolBindId_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);
|
typedef void (*HProtocolBindCallback)(HProtocolBind_t index, uint8_t* data, uint16_t len);
|
||||||
|
|||||||
@ -142,7 +142,7 @@ void HSHellUnregister(int16_t index);
|
|||||||
* @param strLen 命令行数据长度
|
* @param strLen 命令行数据长度
|
||||||
**/
|
**/
|
||||||
void HShellAddCmdData(uint8_t data);
|
void HShellAddCmdData(uint8_t data);
|
||||||
void HSHellAddCmdDatas(const uint8_t *data, int len);
|
void HSHellAddCmdDatas(const void *data, int len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 处理命令行数据, 因添加数据在中断, 执行需在非中断执行
|
* @brief 处理命令行数据, 因添加数据在中断, 执行需在非中断执行
|
||||||
|
|||||||
@ -373,6 +373,11 @@ void HDProtocolRun()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 正在解析使用的协议触发的协议运转, 不要继续重叠处理
|
||||||
|
if (i == sInfo.useIndex) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (i >= OCCUPIED_MAX) {
|
if (i >= OCCUPIED_MAX) {
|
||||||
LogE("index[%d] is out of range[%d]", i, OCCUPIED_MAX);
|
LogE("index[%d] is out of range[%d]", i, OCCUPIED_MAX);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -461,13 +461,14 @@ void HShellAddCmdData(uint8_t data) {
|
|||||||
AddCmdData(data);
|
AddCmdData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HSHellAddCmdDatas(const uint8_t *data, int len) {
|
void HSHellAddCmdDatas(const void *data, int len) {
|
||||||
if (shellInfo_.run) {
|
if (shellInfo_.run || data == NULL) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint8_t *d = (const uint8_t *)data;
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
AddCmdData(data[i]);
|
AddCmdData(d[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user