diff --git a/build/crc16.o b/build/crc16.o index 6e7fb7a..2af0e39 100644 Binary files a/build/crc16.o and b/build/crc16.o differ diff --git a/build/erpc_core.o b/build/erpc_core.o index 4ef1d04..bd19ae2 100644 Binary files a/build/erpc_core.o and b/build/erpc_core.o differ diff --git a/build/port_self.o b/build/port_self.o index 3ffa0f2..33c53e0 100644 Binary files a/build/port_self.o and b/build/port_self.o differ diff --git a/erpc_core.c b/erpc_core.c index 4a708ab..b2e0a95 100644 --- a/erpc_core.c +++ b/erpc_core.c @@ -131,7 +131,7 @@ u32 erpc_send_base(erpc_hw_cfg_t *hw_cfg, u8 dest_id, u16 port, u8 package_type, { if (hw_cfg->send_cache[i].state == ERPC_CMD_NO_ERROR) { - ERPC_DEBUG("find send cache %d\n", i); + // ERPC_DEBUG("find send cache %d\n", i); cache_ord = i; break; } @@ -377,7 +377,18 @@ u32 erpc_rev_package(erpc_hw_cfg_t *hw) { if (hw->rec_cache[i].state == ERPC_CMD_WAIT_SERVER_DEAL) { - ERPC_DEBUG("find cmd wait server deal %d\n", i); + hw->deal_lock(); + if (hw->rec_cache[i].state == ERPC_CMD_WAIT_SERVER_DEAL) + { + hw->rec_cache[i].state = ERPC_CMD_SERVER_DEAL; + } + else + { + hw->deal_unlock(); + continue; + } + hw->deal_unlock(); + // ERPC_DEBUG("find cmd wait server deal %d\n", i); erpc_cmd_def_t *cmd = (erpc_cmd_def_t *)&hw->rec_cache[i].data[0]; // 检查crc u8 crc_result = cmd_check_crc16(cmd); @@ -403,6 +414,7 @@ u32 erpc_rev_package(erpc_hw_cfg_t *hw) break; case PACKAGE_TYPE_CMD_REQ_ACK: ERPC_DEBUG("{ACK}\n"); + erpc_rev_ack_package(hw, cmd); hw->rec_cache[i].state = ERPC_CMD_NO_ERROR; break; @@ -451,7 +463,7 @@ u32 erpc_set_rev_cahce(u8 hw, u8 *data, u16 len) { if (hw_cfg->rec_cache[i].state == ERPC_CMD_NO_ERROR) { - ERPC_DEBUG("set rev cache %d\r\n", i); + // ERPC_DEBUG("set rev cache %d\r\n", i); memcpy(hw_cfg->rec_cache[i].data, data, len); hw_cfg->rec_cache[i].state = ERPC_CMD_WAIT_SERVER_DEAL; return ERPC_NO_ERROR; diff --git a/erpc_core.h b/erpc_core.h index 07e1fc5..a8560b1 100644 --- a/erpc_core.h +++ b/erpc_core.h @@ -49,6 +49,7 @@ typedef enum erpc_status { ERPC_CMD_NO_ERROR, // 发送cache,接收cache空闲 ERPC_CMD_DATA_DEAL, // 发送cache数据组织中 ERPC_CMD_WAIT_SERVER_DEAL, // 等待服务线程处理接受cache + ERPC_CMD_SERVER_DEAL, // 服务线程处理接受cache ERPC_CMD_WAIT_TASK_DEAL, // 等待任务线程处理指令 ERPC_CMD_WAIT_TASK_DEAL_FINISH, // 等待任务线程处理指令完成 ERPC_CMD_WAIT_SEND, // 等待服务线程处理发送cache diff --git a/port_self.c b/port_self.c index cc3b1bc..5c752d1 100644 --- a/port_self.c +++ b/port_self.c @@ -114,7 +114,19 @@ DWORD WINAPI send_task(LPVOID lpParam) erpc_send_deal_core(); } } -DWORD WINAPI rev_task(LPVOID lpParam) +DWORD WINAPI rev_package_task(LPVOID lpParam) +{ + UNUSED(lpParam); + + while (1) + { + // ERPC_DEBUG("rev_task\n"); + erpc_rev_package_core(); + erpc_rev_deal_core(); + } +} + +DWORD WINAPI rev_deal_task(LPVOID lpParam) { UNUSED(lpParam); @@ -180,8 +192,8 @@ int main(int argc, char *argv[]) return 1; } threadHandle[0] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)send_task, NULL, 0, NULL); - threadHandle[1] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)rev_task, NULL, 0, NULL); - threadHandle[3] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)rev_task, NULL, 0, NULL); + threadHandle[1] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)rev_package_task, NULL, 0, NULL); + threadHandle[3] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)rev_deal_task, NULL, 0, NULL); threadHandle[4] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_task, NULL, 0, NULL); WaitForSingleObject(threadHandle[0], INFINITE); diff --git a/port_self.exe b/port_self.exe index 3e587f7..d6c9988 100644 Binary files a/port_self.exe and b/port_self.exe differ