Raspberry pi pico w UDP socket recv buffer issue #13214
Replies: 2 comments
-
There have been quite few reports of network issues running on the second processor. I try to only use the thread for compute-intensive, tasks, and keep all I/O on the main processor. This usually results in a lot better outcomes. You might try recasting the I/O part to run on the main processor, using some asyncio bits. Note that the UDP/asyncio official code has been worked out yet, but you can just use some polls of the socket, along with await asyncio.sleep() calls, to get mostly asyncio code. |
Beta Was this translation helpful? Give feedback.
-
@mendenm thanks for letting me know about the asyncio option. I will look into that option as well. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have created a UDP socket client for the pi pico w. The UDP client is using MicroPython. The sock.recvfrom function behave unpredictable on the pi pico w. It looks like the receive UDP buffer is blocked till the sock.sendto is called. The received datagrams is lagging behind the expected arrival patten. This may be due to the WLAN only working on one core limitation but I also have tried moving the sock.recvfrom to the main thread with no lack. The UDP server reply to every message send.
MicroPython v1.21.0 on pi pico w and ESP32 and Python 3.11.4 on Windows 10
pi pico w UDP client (don't work as expected):
output server / client:
Received from client ('111.111.40.9', 56254): keepalive1 no client output
Received from client ('111.111.40.9', 56254): keepalive2 Received from server ('222.222.178.98', 8266): keepalive1
Received from client ('111.111.40.9', 56254): keepalive3 Received from server ('222.222.178.98', 8266): keepalive2
ESP32 UDP client (work as expected):
output server / client:
Received from client ('111.111.40.9', 50045): keepalive0 Received from server ('222.222.178.98', 8266): keepalive0
Received from client ('111.111.40.9', 50045): keepalive1 Received from server ('222.222.178.98', 8266): keepalive1
Received from client ('111.111.40.9', 50045): keepalive2 Received from server ('222.222.178.98', 8266): keepalive2
Windows 10 UDP client (work as expected):
output server / client:
Received from client ('111.111.40.9', 49921): keepalive0 Received from server ('222.222.178.98', 8266): keepalive0
Received from client ('111.111.40.9', 49921): keepalive1 Received from server ('222.222.178.98', 8266): keepalive1
Received from client ('111.111.40.9', 49921): keepalive2 Received from server ('222.222.178.98', 8266): keepalive2
Beta Was this translation helpful? Give feedback.
All reactions