fix(simple cmd) 完成简单通讯
This commit is contained in:
parent
8357f41a75
commit
70fb05c650
38
erpc_core.c
38
erpc_core.c
|
@ -173,15 +173,18 @@ u32 erpc_send(u8 hw, u8 dest_id, u16 port, u8 *data, u16 len)
|
|||
u32 ret = ERPC_NO_ERROR;
|
||||
do
|
||||
{
|
||||
if(wait_time == 0){
|
||||
if (wait_time == 0)
|
||||
{
|
||||
ret = ERPC_ERR_SEND_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
if(hw_cfg->send_cache[cache_ord].state == ERPC_CMD_SEND_ONCE){
|
||||
if (hw_cfg->send_cache[cache_ord].state == ERPC_CMD_SEND_ONCE)
|
||||
{
|
||||
ret = ERPC_ERR_DEST_NO_RESPONSE;
|
||||
break;
|
||||
}
|
||||
if(hw_cfg->send_cache[cache_ord].state == ERPC_CMD_SEND_REPEAT){
|
||||
if (hw_cfg->send_cache[cache_ord].state == ERPC_CMD_SEND_REPEAT)
|
||||
{
|
||||
ret = ERPC_ERR_DEST_NO_RESPONSE;
|
||||
break;
|
||||
}
|
||||
|
@ -190,8 +193,6 @@ u32 erpc_send(u8 hw, u8 dest_id, u16 port, u8 *data, u16 len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
u32 erpc_send_data(erpc_hw_cfg_t *hw)
|
||||
{
|
||||
for (int i = 0; i < MAX_SEND_CMD_CACHE_NUM; i++)
|
||||
|
@ -367,13 +368,16 @@ void erpc_rev_deal_core()
|
|||
while (list != NULL)
|
||||
{
|
||||
erpc_hw_cfg_t *hw = (erpc_hw_cfg_t *)list->data;
|
||||
|
||||
{ // 遍历接收缓存
|
||||
for (int j = 0; j < MAX_REC_CMD_CACHE_NUM; j++)
|
||||
{
|
||||
// 发现等待处理的数据包
|
||||
if (hw->rec_cache[j].state == ERPC_CMD_WAIT_TASK_DEAL)
|
||||
{ // 发现等待处理的数据包
|
||||
if (hw->rec_cache[j].state != ERPC_CMD_WAIT_TASK_DEAL)
|
||||
{
|
||||
// 多线程处理
|
||||
continue;
|
||||
}
|
||||
}
|
||||
{ // 多线程下,抢占处理权限
|
||||
hw->deal_lock();
|
||||
if (hw->rec_cache[j].state == ERPC_CMD_WAIT_TASK_DEAL)
|
||||
{
|
||||
|
@ -387,6 +391,8 @@ void erpc_rev_deal_core()
|
|||
continue;
|
||||
}
|
||||
hw->deal_unlock();
|
||||
}
|
||||
{ // 处理指令
|
||||
// 搜索指令列表
|
||||
list_t *cmd_list = &hw->cmd_list;
|
||||
// 链表是空的
|
||||
|
@ -394,10 +400,11 @@ void erpc_rev_deal_core()
|
|||
{
|
||||
continue;
|
||||
}
|
||||
while (cmd_list != NULL)
|
||||
{
|
||||
erpc_cmd_list_t *cmd_obj = (erpc_cmd_list_t *)cmd_list->data;
|
||||
// 获取指令指针
|
||||
erpc_cmd_def_t *cmd_def = (erpc_cmd_def_t *)hw->rec_cache[j].data;
|
||||
while (cmd_list != NULL)
|
||||
{ // 搜索指令列表
|
||||
erpc_cmd_list_t *cmd_obj = (erpc_cmd_list_t *)cmd_list->data;
|
||||
if (cmd_obj->cmd == cmd_def->head.port)
|
||||
{
|
||||
if (cmd_obj->handle != NULL)
|
||||
|
@ -405,12 +412,15 @@ void erpc_rev_deal_core()
|
|||
// 指令调用
|
||||
cmd_obj->handle(hw->ord, cmd_def->head.src_id, cmd_def->head.dest_id, cmd_def->head.port, cmd_def->data, cmd_def->head.msg_len);
|
||||
}
|
||||
// 处理完成 丢弃缓存
|
||||
hw->rec_cache[j].state = ERPC_CMD_NO_ERROR;
|
||||
|
||||
break;
|
||||
}
|
||||
cmd_list = cmd_list->next;
|
||||
}
|
||||
}
|
||||
// 处理完成 丢弃缓存 , 无论是否执行指令,都需要把数据包丢弃
|
||||
hw->rec_cache[j].state = ERPC_CMD_NO_ERROR;
|
||||
}
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
|
|
BIN
erpc_core.o
BIN
erpc_core.o
Binary file not shown.
|
@ -93,6 +93,7 @@ DWORD WINAPI test_task(LPVOID lpParam)
|
|||
{
|
||||
// printf("[test_task]send\n");
|
||||
u32 ret = erpc_send(self_hw_cfg.ord, self_hw_cfg.local_id, 0x01, NULL, 0);
|
||||
ret = erpc_send(self_hw_cfg.ord, self_hw_cfg.local_id, 0x02, NULL, 0);
|
||||
printf("[test_task]send ret:%d\n", ret);
|
||||
sys_sleep(1000);
|
||||
}
|
||||
|
|
BIN
port_self.exe
BIN
port_self.exe
Binary file not shown.
BIN
port_self.o
BIN
port_self.o
Binary file not shown.
Loading…
Reference in New Issue