TobudOS icon indicating copy to clipboard operation
TobudOS copied to clipboard

接收的消息同时含有期望的字符串和“OK”时,at_echo->__expect_notify还没来得及获取,at_echo->status = AT_ECHO_STATUS_EXPECT;就立马有被任务“at_parser”更新成at_echo->status = AT_ECHO_STATUS_OK;

Open zhaoxwgit opened this issue 2 years ago • 3 comments

    if (at_parse_status == AT_PARSE_STATUS_EXPECT) {
        at_echo->status = AT_ECHO_STATUS_EXPECT;
        if (at_echo->__is_expecting) {
            tos_sem_post(&at_echo->__expect_notify);
        }
    } else if (at_parse_status == AT_PARSE_STATUS_OK) {
        if (!at_echo->__is_expecting) {
        	at_echo->status = AT_ECHO_STATUS_OK;
            tos_sem_post(&at_echo->__status_set_notify);
        }
    } else if (at_parse_status == AT_PARSE_STATUS_FAIL) {
        at_echo->status = AT_ECHO_STATUS_FAIL;
        if (!at_echo->__is_expecting) {
            tos_sem_post(&at_echo->__status_set_notify);
        }
    } else if (at_parse_status == AT_PARSE_STATUS_ERROR) {
        at_echo->status = AT_ECHO_STATUS_ERROR;
        if (!at_echo->__is_expecting) {
            tos_sem_post(&at_echo->__status_set_notify);
        }
    }

zhaoxwgit avatar Mar 10 '22 06:03 zhaoxwgit

if (!at_echo->__is_expecting) {

这里是!,__is_expecting=1时,不会进入到at_echo->status = AT_ECHO_STATUS_OK的逻辑,您是在实际使用时碰到了这个异常情况吗?

Mculover666 avatar Mar 11 '22 03:03 Mculover666

接收的消息同时含有期望的字符串和“OK”时,at_echo->__expect_notify还没来得及获取,at_echo->status = AT_ECHO_STATUS_EXPECT;就立马有被任务“at_parser”更新成at_echo->status = AT_ECHO_STATUS_OK;这样等tos_sem_pend (&at_echo->__expect_notify);时已经变了,直接跳过了。实际遇到的。

zhaoxwgit avatar Mar 11 '22 05:03 zhaoxwgit

建议在得到状态后,找个合适的地方清除 recv_cache

zhaoxwgit avatar Mar 11 '22 06:03 zhaoxwgit