fix(port_self): 增加一个线程,防止卡住
This commit is contained in:
parent
45aa9278fe
commit
03ea55fdc9
Binary file not shown.
Binary file not shown.
|
@ -187,6 +187,7 @@ u32 erpc_send_base(erpc_hw_cfg_t *hw_cfg, u8 dest_id, u16 port, u8 package_type,
|
|||
{
|
||||
if (wait_time == 0)
|
||||
{
|
||||
printf("send timeout,state:%d\n", hw_cfg->send_cache[cache_ord].state);
|
||||
ret = ERPC_ERR_SEND_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
|
|
19
port_self.c
19
port_self.c
|
@ -32,6 +32,8 @@ u32 hello_cat(u8 hw, u8 src_id, u8 dest_id, u16 port, u8 *data, u16 len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
u32 hello_dog(u8 hw, u8 src_id, u8 dest_id, u16 port, u8 *data, u16 len)
|
||||
{
|
||||
ERPC_DEBUG("Hello Dog!\n");
|
||||
|
@ -136,8 +138,16 @@ DWORD WINAPI test_task(LPVOID lpParam)
|
|||
ERPC_DEBUG("[test_task]send ret:%d\n", ret);
|
||||
ret = erpc_send(self_hw_cfg.ord, self_hw_cfg.local_id, 0x02, NULL, 0);
|
||||
ERPC_DEBUG("[test_task]send ret:%d\n", ret);
|
||||
ret = erpc_send_wait_reply(self_hw_cfg.ord, self_hw_cfg.local_id, 0x03, NULL, 0, data, NULL, 1000);
|
||||
u16 reply_len = 30;
|
||||
u8 data[reply_len];
|
||||
ret = erpc_send_wait_reply(self_hw_cfg.ord, self_hw_cfg.local_id, 0x03, NULL, 0, data, &reply_len, 1000);
|
||||
ERPC_DEBUG("[test_task]send ret:%d\n", ret);
|
||||
for (int i = 0; i < reply_len; i++)
|
||||
{
|
||||
ERPC_DEBUG("%c", data[i]);
|
||||
}
|
||||
ERPC_DEBUG("\n");
|
||||
|
||||
UNUSED(ret);
|
||||
sys_sleep(1000);
|
||||
}
|
||||
|
@ -156,7 +166,7 @@ int main(int argc, char *argv[])
|
|||
ERPC_DEBUG("erpc_cmd_config ret:%d\n", ret);
|
||||
erpc_sleep_tick = sys_sleep;
|
||||
|
||||
HANDLE threadHandle[3];
|
||||
HANDLE threadHandle[4];
|
||||
deal_lock = CreateMutex(NULL, FALSE, NULL);
|
||||
if (deal_lock == NULL)
|
||||
{
|
||||
|
@ -171,13 +181,16 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
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[2] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_task, NULL, 0, NULL);
|
||||
threadHandle[3] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)rev_task, NULL, 0, NULL);
|
||||
threadHandle[4] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_task, NULL, 0, NULL);
|
||||
|
||||
WaitForSingleObject(threadHandle[0], INFINITE);
|
||||
WaitForSingleObject(threadHandle[1], INFINITE);
|
||||
WaitForSingleObject(threadHandle[2], INFINITE);
|
||||
WaitForSingleObject(threadHandle[3], INFINITE);
|
||||
CloseHandle(threadHandle[0]);
|
||||
CloseHandle(threadHandle[1]);
|
||||
CloseHandle(threadHandle[2]);
|
||||
CloseHandle(threadHandle[3]);
|
||||
return 0;
|
||||
}
|
BIN
port_self.exe
BIN
port_self.exe
Binary file not shown.
Loading…
Reference in New Issue