espnow发送存在延时该如何处理

fishxxx
Posts: 3
Joined: Sun Feb 04, 2024 7:59 am

espnow发送存在延时该如何处理

Postby fishxxx » Mon Apr 15, 2024 1:25 am

用串口接收数据然后调用espnow透传,espnow用广播方式发送,发现从调用esp_now_send之后到系统调用注册的espnow_send_cb之间总是有一个随机的延时存在,从10ms-50ms不等。整个例程代码一共只有串口接收和espnow接收两个任务,从串口接收到的数据立即会立即发送,发送器log如下:
�[0;31mE (1956376) uart_port: dt = 244�[0m
�[0;31mE (1956379) my_espnow2: dt = 236�[0m
�[0;31mE (1956620) uart_port: dt = 244�[0m
�[0;31mE (1956628) my_espnow2: dt = 248�[0m
�[0;31mE (1956864) uart_port: dt = 244�[0m
�[0;31mE (1956866) my_espnow2: dt = 238�[0m
�[0;31mE (1957108) uart_port: dt = 244�[0m
�[0;31mE (1957114) my_espnow2: dt = 248�[0m
�[0;31mE (1957352) uart_port: dt = 244�[0m
�[0;31mE (1957359) my_espnow2: dt = 245�[0m
�[0;31mE (1957596) uart_port: dt = 244�[0m
�[0;31mE (1957653) my_espnow2: dt = 294�[0m
�[0;31mE (1957840) uart_port: dt = 244�[0m
�[0;31mE (1957842) my_espnow2: dt = 189�[0m
�[0;31mE (1958084) uart_port: dt = 244�[0m
串口发送间隔是244ms。这个发送间隔计算写于串口接收之后、esp_now_send之前;espnow的发送完成间隔计算写于espnow_send_cb中,接收器的espnow接收任务中也计算了接收间隔,与发送端是匹配的。理想情况下,发送间隔是244ms,那么发送完成间隔也应该是244ms,接收间隔也应该是244ms,到底什么事件会产生这样一个延时?望指点。

我的开发板是esp32-c3,使用的idf版本是5.1.3,后来我又尝试用show example里的espnow例程来看发送是否存在延时,在espnow_send_cb计算了一下发送完成间隔。结论也是一样,发送间隔固定,但发送完成间隔不固定,最严重的时候有个30ms延迟。

随后我又在调用esp_now_send之后和系统调用espnow_send_cb之间计算了时间差,log如下:
�[0;31mE (437617) my_espnow2: dt = 7�[0m
�[0;31mE (437787) my_espnow2: dt = 3�[0m
�[0;31mE (437949) my_espnow2: dt = 2�[0m
�[0;31mE (438130) my_espnow2: dt = 10�[0m
�[0;31mE (438336) my_espnow2: dt = 20�[0m
�[0;31mE (438509) my_espnow2: dt = 6�[0m
�[0;31mE (438674) my_espnow2: dt = 2�[0m
�[0;31mE (438848) my_espnow2: dt = 11�[0m
�[0;31mE (439023) my_espnow2: dt = 12�[0m
�[0;31mE (439198) my_espnow2: dt = 2�[0m
�[0;31mE (439362) my_espnow2: dt = 2�[0m
�[0;31mE (439534) my_espnow2: dt = 6�[0m
�[0;31mE (439704) my_espnow2: dt = 2�[0m
�[0;31mE (439896) my_espnow2: dt = 2�[0m
�[0;31mE (440063) my_espnow2: dt = 5�[0m
�[0;31mE (440254) my_espnow2: dt = 11�[0m
�[0;31mE (440414) my_espnow2: dt = 2�[0m
�[0;31mE (440581) my_espnow2: dt = 3�[0m
�[0;31mE (440772) my_espnow2: dt = 31�[0m

发送完成时间间隔十分随机,甚至有长达31ms的,有什么办法或者配置可以消除这种随机性,让数据可以立即发出么?

Who is online

Users browsing this forum: Bing [Bot] and 60 guests