From 70fb05c6503dbda036e070d5f86b4c2e632a6a7a Mon Sep 17 00:00:00 2001 From: chenyf <1343619937@qq.com> Date: Thu, 21 Nov 2024 00:26:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(simple=20cmd)=20=E5=AE=8C=E6=88=90=E7=AE=80?= =?UTF-8?q?=E5=8D=95=E9=80=9A=E8=AE=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erpc_core.c | 116 +++++++++++++++++++++++++++----------------------- erpc_core.o | Bin 6260 -> 6276 bytes port_self.c | 1 + port_self.exe | Bin 70831 -> 70831 bytes port_self.o | Bin 10021 -> 10099 bytes 5 files changed, 64 insertions(+), 53 deletions(-) diff --git a/erpc_core.c b/erpc_core.c index 570de48..2bd711c 100644 --- a/erpc_core.c +++ b/erpc_core.c @@ -173,25 +173,26 @@ u32 erpc_send(u8 hw, u8 dest_id, u16 port, u8 *data, u16 len) u32 ret = ERPC_NO_ERROR; do { - if(wait_time == 0){ - ret = ERPC_ERR_SEND_TIMEOUT; - break; - } - 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){ - ret = ERPC_ERR_DEST_NO_RESPONSE; - break; - } + if (wait_time == 0) + { + ret = ERPC_ERR_SEND_TIMEOUT; + break; + } + 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) + { + ret = ERPC_ERR_DEST_NO_RESPONSE; + break; + } } while (0); hw_cfg->send_cache[cache_ord].state = ERPC_CMD_NO_ERROR; return ret; } - - u32 erpc_send_data(erpc_hw_cfg_t *hw) { for (int i = 0; i < MAX_SEND_CMD_CACHE_NUM; i++) @@ -367,49 +368,58 @@ 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) + { // 遍历接收缓存 + for (int j = 0; j < MAX_REC_CMD_CACHE_NUM; j++) { - // 多线程处理 - hw->deal_lock(); - if (hw->rec_cache[j].state == ERPC_CMD_WAIT_TASK_DEAL) - { - // 获取指令的处理权限 - hw->rec_cache[j].state = ERPC_CMD_WAIT_TASK_DEAL_FINISH; - } - else - { - // 已经有线程抢先执行了 - hw->deal_unlock(); - continue; - } - hw->deal_unlock(); - // 搜索指令列表 - list_t *cmd_list = &hw->cmd_list; - // 链表是空的 - if (cmd_list->data == NULL) - { - 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; - if (cmd_obj->cmd == cmd_def->head.port) + { // 发现等待处理的数据包 + if (hw->rec_cache[j].state != ERPC_CMD_WAIT_TASK_DEAL) { - if (cmd_obj->handle != NULL) - { - // 指令调用 - 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; + continue; } - cmd_list = cmd_list->next; } + { // 多线程下,抢占处理权限 + hw->deal_lock(); + if (hw->rec_cache[j].state == ERPC_CMD_WAIT_TASK_DEAL) + { + // 获取指令的处理权限 + hw->rec_cache[j].state = ERPC_CMD_WAIT_TASK_DEAL_FINISH; + } + else + { + // 已经有线程抢先执行了 + hw->deal_unlock(); + continue; + } + hw->deal_unlock(); + } + { // 处理指令 + // 搜索指令列表 + list_t *cmd_list = &hw->cmd_list; + // 链表是空的 + if (cmd_list->data == NULL) + { + continue; + } + // 获取指令指针 + 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) + { + // 指令调用 + 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); + } + + break; + } + cmd_list = cmd_list->next; + } + } + // 处理完成 丢弃缓存 , 无论是否执行指令,都需要把数据包丢弃 + hw->rec_cache[j].state = ERPC_CMD_NO_ERROR; } } list = list->next; diff --git a/erpc_core.o b/erpc_core.o index d9d50ac2cbe424258a49de7477193b386e931a5a..f4ec43652f5900f2c1abc5a755018f5cc29cc63f 100644 GIT binary patch delta 378 zcmexj&|=7$(#FmJ0(uiUr8xum7#MUI85lw)>J~HBOkAkWY9PSCkTdbDGUJnpAJrK} zHcK*w@yLDwDtUPVNO*L+{_yB#@aS}XaNP9^$e5S2C-?BGG8RnU#B0dtHMyTxdh&l> z4arjRmp_2AK=ltix*Hrs7#RLvc=-${GTEO`Df7n5eu(4?h+!9i>Mrna7XVT>__sT7 zq*)#+O#z8{bUSc(v>qra0C9Y}1317cwmER|Z#w~E`gBLYHM#I_2aEA`-PLgFZ$pA z|3EE3pMtgg0BZRG)S?R%o~+BOz?Tqvcme`!&g4&KWOUkmR-l@ZTL~DT;y}N#Fz9U# O7BXfAinoitWdZ;$CyY)2 delta 344 zcmZoM{9?eF(#FmJ0&){Mr8yn=7#MUI85mq9>J~HROkAkWsvy9?5Hs z4GsR*mmtaaKmw@efk$_Pg9rn|{|hhgLPTCbOt~@Hfln#+0#L~f{_O%l>H`0E2aYt$ zL;S4`5QR59x*a$?S`U ze)4HPIgqndkAa;6v>0e!r|S!k=Gqqw{H@CW|Nn1x{leH>`-PLgFJZDFzZi?rzyJRy u>+&ivC&V7!T*;rz$Y{Iyu0S;-w=6KY#DVT&VbI*1EM&|K6rV2omI(m6d3K!u diff --git a/port_self.c b/port_self.c index 7ccedb9..36f6f70 100644 --- a/port_self.c +++ b/port_self.c @@ -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); } diff --git a/port_self.exe b/port_self.exe index 0ea715d5bc6d22dd2666b30ad5679ccf16d3eb52..364981f7047306221cc72e78ce6a0797d8f0b506 100644 GIT binary patch delta 6368 zcmZ`-3s_X;x?ca1Q9yAJ7(ifP7#KtW9Y6+Zrw$6bRMgS5bbG^XlJ`a(%u0e2nNA}H zejf9jZ96HPIfB(<#IXe2B7D!(L9%; zayG!KU~faJCTrI%Y!oGR>!C@<)*jCoz) zKdJO)B1$Oyn;_H+41#kP9rYc+UZ#7#S|kbeyTVq|L%(^9Xtw{0Vq^$i@;CR~5yC6a zZ9^H(ua!U(unXMEA8rM@}pAt~v!}idPUJmx5eRt5$jD1S) zhNQC1^hL-K^?ls8wE-77qYYz`+ftuQq0q8WZE@BqJcfSX zqZ=jYi2i*PqI*RN7+S@RejFOXT4+pfb@B9{v6^!q!{6WDvPWi)`kZ(TMoY-vFJEg# z02X7CJHnRxST2ot@~x2=T4xt94F;xlB`%&COuPi^q;TiRZrB;Qk9jJTRLG+WB86h^ z48i@J@BJhf;!QiBcNmMbrA3bgi+?STYrT%yb1uisdV5Xgy%Nz26LG=BGpj23#9ITi z<%k13OfDZCw%YjA%LA%NE=6Z+prkERXgS6DUgao^MX!BwFZt2JdG?buDMDiy`-j*B z?06nqrikLKBXm|r=#h~KEu{A%`UKy_dC{p3=bQ9>gf{5RpLIL+j*JWX@XzwAG&VB4 zIK^E6_Q4<4Ubt7h^9QkuS8Q>wtjIUz$L2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