我参考文档(https://docs.espressif.com/projects/esp ... mmand-port),读取未指定长度的数据,收到的数据不完整,是什么原因?下面是循环的代码,比如我在AT port输入了一段数据,主要是"remain_len = esp_at_port_get_data_length();"这里,数据未接收完,为什么remain_len是0?
while (xSemaphoreTake(s_at_sync_sema, portMAX_DELAY)) {
memset(s_buffer, 0, sizeof(s_buffer));
received_len =
esp_at_port_read_data((uint8_t *)s_buffer, sizeof(s_buffer) - 1);
if (received_len == 0)
continue;
if ((received_len == 5 && strncmp(s_buffer, "+++\r\n", 5) == 0) ||
(received_len == 3 && strncmp(s_buffer, "+++", 3) == 0)) {
esp_at_port_exit_specific();
break;
}
s_buffer[received_len] = '\0'; // 确保字符串以 null 结尾
COPY_BUFFER(s_buffer); // 复制s_buffer到另外的buffer
remain_len = esp_at_port_get_data_length();
if (remain_len > 0) { // 数据未完整,继续读取
esp_at_port_recv_data_notify(remain_len, portMAX_DELAY);
} else {
PROCESS_BUFFER(); // 数据完整,处理
}
}
自定义AT命令,读取的数据不完整
Moderator: XCGuang
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- ESP32-S31
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- ESP32-S31 中文讨论版
- 喵伴 中文讨论版
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 2 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.
Information
Espressif ESP32 ... Available now!