fix:null
This commit is contained in:
parent
c618a1b918
commit
1d81a3b02c
52
erpc_core.c
52
erpc_core.c
|
@ -205,6 +205,56 @@ u32 erpc_send_base(erpc_hw_cfg_t *hw_cfg, u8 dest_id, u16 port, u8 package_type,
|
|||
hw_cfg->send_cache[cache_ord].state = ERPC_CMD_NO_ERROR;
|
||||
return ret;
|
||||
}
|
||||
u32 erpc_boardcast(u16 port, u8 *data, u16 len)
|
||||
{
|
||||
list_t *list = &erpc_hw;
|
||||
if (list->data == NULL)
|
||||
{
|
||||
return ERPC_ERR_NOFOND_HW;
|
||||
}
|
||||
while (list != NULL)
|
||||
{
|
||||
erpc_hw_cfg_t *hw_cfg = (erpc_hw_cfg_t *)list->data;
|
||||
u8 cache_ord = 255;
|
||||
// 查找可用的发送缓存
|
||||
for (int i = 0; i < MAX_SEND_CMD_CACHE_NUM; i++)
|
||||
{
|
||||
if (hw_cfg->send_cache[i].state == ERPC_CMD_NO_ERROR)
|
||||
{
|
||||
// ERPC_DEBUG("find send cache %d\n", i);
|
||||
cache_ord = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cache_ord == 255)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// 准备数据
|
||||
hw_cfg->send_cache[cache_ord].state = ERPC_CMD_DATA_DEAL;
|
||||
erpc_cmd_def_t *cmd =
|
||||
(erpc_cmd_def_t *)&hw_cfg->send_cache[cache_ord].data[0];
|
||||
cmd->head.dest_id = ERPC_BOARDCAST_ID;
|
||||
cmd->head.port = port;
|
||||
cmd->head.src_id = hw_cfg->local_id;
|
||||
cmd->head.msg_len = len;
|
||||
if (data == NULL)
|
||||
{
|
||||
cmd->head.msg_len = 0;
|
||||
}
|
||||
if (len > 0 && data != NULL)
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
cmd->data[i] = data[i];
|
||||
}
|
||||
}
|
||||
// 计算校验和
|
||||
cmd_cal_crc16(cmd);
|
||||
hw_cfg->send_cache[cache_ord].state = ERPC_CMD_WAIT_SEND;
|
||||
}
|
||||
}
|
||||
|
||||
u32 erpc_send(u8 hw, u8 dest_id, u16 port, u8 *data, u16 len)
|
||||
{
|
||||
erpc_hw_cfg_t *hw_cfg = erpc_hw_get(hw);
|
||||
|
@ -561,4 +611,4 @@ void erpc_rev_deal_core()
|
|||
{
|
||||
erpc_sleep_tick(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,4 +135,11 @@ u32 erpc_send_wait_reply(u8 hw, u8 dest_id, u16 port, u8 *data, u16 len,
|
|||
* 回复消息
|
||||
*/
|
||||
u32 erpc_replay(u8 hw, u8 dest_id, u16 port, u8 *data_out, u16 len);
|
||||
|
||||
/**
|
||||
* 广播消息
|
||||
*/
|
||||
u32 erpc_boardcast(u16 port, u8 *data, u16 len);
|
||||
|
||||
|
||||
#endif /* ERPC_CORE_H_ */
|
|
@ -0,0 +1,3 @@
|
|||
#include "erpc_net.h"
|
||||
#include "erpc_core.h"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#include "erpc_core.h"
|
||||
|
||||
u32 erpc_find_all();
|
Loading…
Reference in New Issue