最近基于esp-mesh-lit>examples>no_router的demo改写了一个从串口接收数据,然后广播到组网设备的功能。
验证功能过程中发现,每次调用esp_mesh_lite_try_sending_msg,可用的free heap就越来越少,多次调用后,系统因为heap不够奔溃了。
起初是以为cJSON的item没有释放掉,但查到后面发现只要注释掉esp_mesh_lite_try_sending_msg这个api,heap就正常,大伙有碰到过类似的问题么?
使用的硬件是esp32-c3-mini-1开发板,
各依赖组件版本如下:
[1/5] espressif/cmake_utilities (0.5.3)
[2/5] espressif/esp_modem (1.1.0)
[3/5] espressif/iot_bridge (0.11.0)
[4/5] espressif/mesh_lite (0.10.0)
[5/5] idf (5.1.2)
下面是部分log,
I (561116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -14, free heap: 167884
I (571116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167884
I (581116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167884
I (591116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167884
I (601116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -14, free heap: 167752
I (604216) uart_port: uart1 recv, count: 0, len: 4
I (605076) uart_port: uart1 recv, count: 1, len: 4
I (605596) uart_port: uart1 recv, count: 2, len: 4
I (605856) uart_port: uart1 recv, count: 3, len: 4
I (611116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167380
I (613746) uart_port: uart1 recv, count: 4, len: 4
I (613926) uart_port: uart1 recv, count: 5, len: 4
I (614136) uart_port: uart1 recv, count: 6, len: 4
I (614346) uart_port: uart1 recv, count: 7, len: 4
I (621116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167036
I (623196) uart_port: uart1 recv, count: 8, len: 4
I (623416) uart_port: uart1 recv, count: 9, len: 4
I (623586) uart_port: uart1 recv, count: 10, len: 4
I (623816) uart_port: uart1 recv, count: 11, len: 4
I (631116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -14, free heap: 166688
I (631856) uart_port: uart1 recv, count: 12, len: 4
I (632036) uart_port: uart1 recv, count: 13, len: 4
I (632226) uart_port: uart1 recv, count: 14, len: 4
I (632436) uart_port: uart1 recv, count: 15, len: 4
I (641116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166348
I (642306) uart_port: uart1 recv, count: 16, len: 4
I (642476) uart_port: uart1 recv, count: 17, len: 4
I (642666) uart_port: uart1 recv, count: 18, len: 4
I (642896) uart_port: uart1 recv, count: 19, len: 4
I (651116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166004
I (661116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166004
I (671116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166004
附上实现功能的c文件:
【已解决】调用esp_mesh_lite_try_sending_msg后free heap越来越少的问题
【已解决】调用esp_mesh_lite_try_sending_msg后free heap越来越少的问题
Last edited by fishxxx on Fri Mar 08, 2024 1:42 am, edited 1 time in total.
-
- Posts: 52
- Joined: Wed Sep 23, 2020 12:19 pm
Re: 调用esp_mesh_lite_try_sending_msg后free heap越来越少的问题
用法有一些问题,根节点广播和子节点上报应该区分开 msg_type。附件上传一份通信 API 的参考示例。
Re: 调用esp_mesh_lite_try_sending_msg后free heap越来越少的问题
参考您的示例区分了一下msg_type,测试了一下每次调用esp_mesh_lite_try_sending_msg依然会吃heap,log如下:ESP_TianSW wrote: ↑Wed Feb 21, 2024 11:57 amesp_mesh_lite.c
用法有一些问题,根节点广播和子节点上报应该区分开 msg_type。附件上传一份通信 API 的参考示例。
I (171060) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 164340
I (181060) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 164340
I (181111) no_router: uart1 recv, count: 18, len: 4
I (181126) no_router: broadcast info, count: 18, size: 4
I (181126) no_router: uart1 send 4 bytes
I (181280) no_router: uart1 recv, count: 19, len: 4
I (181290) no_router: broadcast info, count: 19, size: 4
I (181291) no_router: uart1 send 4 bytes
I (181453) no_router: uart1 recv, count: 20, len: 4
I (181461) no_router: broadcast info, count: 20, size: 4
I (181462) no_router: uart1 send 4 bytes
I (181612) no_router: uart1 recv, count: 21, len: 4
I (181653) no_router: broadcast info, count: 21, size: 4
I (181654) no_router: uart1 send 4 bytes
I (181809) no_router: uart1 recv, count: 22, len: 4
I (181820) no_router: broadcast info, count: 22, size: 4
I (181821) no_router: uart1 send 4 bytes
I (191060) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 163472
I (201060) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 163472
I (211060) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 163472
I (214705) no_router: uart1 recv, count: 23, len: 4
I (214713) no_router: broadcast info, count: 23, size: 4
I (214714) no_router: uart1 send 4 bytes
I (214891) no_router: uart1 recv, count: 24, len: 4
I (214904) no_router: broadcast info, count: 24, size: 4
I (214904) no_router: uart1 send 4 bytes
I (215061) no_router: uart1 recv, count: 25, len: 4
I (215069) no_router: broadcast info, count: 25, size: 4
I (215070) no_router: uart1 send 4 bytes
I (215244) no_router: uart1 recv, count: 26, len: 4
I (215253) no_router: broadcast info, count: 26, size: 4
I (215254) no_router: uart1 send 4 bytes
I (215387) no_router: uart1 recv, count: 27, len: 4
I (215544) no_router: broadcast info, count: 27, size: 4
I (215545) no_router: uart1 send 4 bytes
I (221060) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 162612
I (231060) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 162612
附上更改后的示例代码: 不过测试过程中发现一个有意思现象,同样的代码,当我将esp_mesh_lite_try_sending_msg这个api的第三个参数max_retry置为>0的值时,每次调用这个api时,heap就不再消耗了,下面是将max_retry置为1时的运行log
I (161062) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 167312
I (171062) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 167312
I (181062) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -9, free heap: 167316
I (184368) no_router: uart1 recv, count: 28, len: 4
I (184379) no_router: broadcast info, count: 28, size: 4
I (184380) no_router: uart1 send 4 bytes
I (184529) no_router: uart1 recv, count: 29, len: 4
I (184537) no_router: broadcast info, count: 29, size: 4
I (184537) no_router: uart1 send 4 bytes
I (184728) no_router: uart1 recv, count: 30, len: 4
I (184737) no_router: broadcast info, count: 30, size: 4
I (184737) no_router: uart1 send 4 bytes
I (184902) no_router: uart1 recv, count: 31, len: 4
I (184913) no_router: broadcast info, count: 31, size: 4
I (184913) no_router: uart1 send 4 bytes
I (191062) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 167300
I (201062) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 167300
I (203868) no_router: uart1 recv, count: 32, len: 4
I (203886) no_router: broadcast info, count: 32, size: 4
I (203887) no_router: uart1 send 4 bytes
I (204056) no_router: uart1 recv, count: 33, len: 4
I (204065) no_router: broadcast info, count: 33, size: 4
I (204066) no_router: uart1 send 4 bytes
I (204499) no_router: uart1 recv, count: 34, len: 4
I (204515) no_router: broadcast info, count: 34, size: 4
I (204516) no_router: uart1 send 4 bytes
I (211062) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 167316
I (221062) no_router: System information, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -10, free heap: 167316
最初做这个demo是奔着广播去的,数据不需要重发,所以将max_retry置成0了。
不太理解为什么重发次数置0会引起heap减少,似乎是esp_mesh_lite_try_sending_msg的重发机制有点问题。
-
- Posts: 52
- Joined: Wed Sep 23, 2020 12:19 pm
Re: 调用esp_mesh_lite_try_sending_msg后free heap越来越少的问题
您好,感谢您提出的问题,这个问题已进行了修复,请使用 github 最新的 master 提交再进行测试。
-
- Posts: 52
- Joined: Wed Sep 23, 2020 12:19 pm
Who is online
Users browsing this forum: No registered users and 14 guests