1. 修复协议绑定立刻触发超时问题
This commit is contained in:
parent
1c8727bc9f
commit
c2ed44d4ba
@ -126,8 +126,8 @@ void HDProtocolSendPort(uint8_t dst, const void *data, int len);
|
||||
|
||||
/**
|
||||
* @brief 临时路由发送(用于发送目标端口的数据后, 解析端临时更改目标端口, 通过 HDProtocolGetDest 获取目标端口)
|
||||
* @param src 回送数据数据路由标记
|
||||
* @param dst 需要往那个目标数据口发送
|
||||
* @param src 发送源端口
|
||||
* @param dst 回送后需要转发到的目标端口
|
||||
* @param data 发送数据
|
||||
* @param len 发送数据长度
|
||||
* @param needReadCount 需要读取次数
|
||||
|
||||
@ -32,6 +32,7 @@ typedef uint16_t HProtocolBindFunc_t;
|
||||
///< 协议回调
|
||||
typedef void (*HProtocolBindCallback)(HProtocolBind_t index, uint8_t* data, uint16_t len);
|
||||
#define HPROTOCOL_BIND_CALL_ARGS HProtocolBind_t index, uint8_t* data, uint16_t len
|
||||
#define HPROTOCOL_IS_TIMEOUT() (data == NULL && len == 0)
|
||||
|
||||
///< 协议会话
|
||||
typedef struct HProtocolBindInfo
|
||||
|
||||
@ -235,6 +235,10 @@ void HDProtocolRegisterInit(HDProtocolServerInfo *info, int len)
|
||||
|
||||
uint8_t HDProtocolCurrSend(const void *data, int len)
|
||||
{
|
||||
if (data == NULL || len == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
HDProtocolServerInfo *info = HDProtocolGetCurrInfo();
|
||||
if (info == NULL) {
|
||||
LogD("curr not read call");
|
||||
@ -248,6 +252,10 @@ uint8_t HDProtocolCurrSend(const void *data, int len)
|
||||
|
||||
void HDProtocolSendPort(uint8_t dst, const void *data, int len)
|
||||
{
|
||||
if (data == NULL || len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sInfo.writeCall == NULL || sInfo.info == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -263,6 +271,10 @@ void HDProtocolSendPort(uint8_t dst, const void *data, int len)
|
||||
|
||||
void HDProtocolTmpSend(uint8_t src, uint8_t dst, const void *data, int len, uint8_t needReadCount, uint8_t waitCount)
|
||||
{
|
||||
if (data == NULL || len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sInfo.writeCall == NULL || sInfo.info == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -217,10 +217,11 @@ void HProtocolBindRun(HProtocolBindId_t id)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (HDLogGetTime() - sBindRegisters[id].binds[i].lastTime >= sBindRegisters[id].binds[i].delayMs) {
|
||||
sBindRegisters[id].binds[i].isTimeout = 1;
|
||||
if (HDLogGetTime() - sBindRegisters[id].binds[i].lastTime < sBindRegisters[id].binds[i].delayMs) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sBindRegisters[id].binds[i].isTimeout = 1;
|
||||
// 可能是同一个功能码绑定多个回调
|
||||
if (sBindRegisters[id].binds[i].callback) {
|
||||
sBindRegisters[id].curr = 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user