select.poll() / socket.readinto() dropping UDP packets? #16934
-
Dear Experts - My program (relevant piece listed below) runs on a RPi pico. It is a WiFi hub passing UDP packets from a control computer to a device on a CAN bus and passing responses from the device out back over WiFi to the control computer. The problem is that it is dropping UDP packets that arrive in a particular sequence. I have traced the packets sent from the control computer using tcpdump so know that the packets were transmitted and their timing / latency. There is tracing code in the UDP packet receiver code that dumps the packets as they are received. There is also timing code in the packet receiver to check the timing of the main loop (it uses nonblocking I know what packets are lost because I see them sent in the tcpdump log but not received in the UDP packet receiver log. All packets are the same size (CS2_SIZE, which is 13 bytes - not big). The log shows that packets are sent by the control computer every ~13 ms. The mean response time in the polling loop is 1.7 ms and max response time is 2.2 ms. The mean time outside of the UDP polling loop is 0.7 ms and max time is 0.8 ms. The lost packets are always being sent from the control computer; there are no losses in packets sent from the RPi pico. Consequently, I do not suspect any problems with the wifi network. On this account I cannot see why I am losing packets. I hesitate to think that there is a problem in MicroPython's Signed, Code follows; apologies for not being able to provide a runnable test (it would require the control computer originating the packets as well!). System:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Is it normal practice to use |
Beta Was this translation helpful? Give feedback.
-
Dear All - After doing more research on slow wifi on the RPi pico, I learned about power management on the wifi chip. Testing showed that disabling power management improved wifi response by about a factor of three. With that change, the asyncio code works. (It was also a relief to learn that the code timings were correct.) Signed, |
Beta Was this translation helpful? Give feedback.
Dear All -
After doing more research on slow wifi on the RPi pico, I learned about power management on the wifi chip. Testing showed that disabling power management improved wifi response by about a factor of three. With that change, the asyncio code works. (It was also a relief to learn that the code timings were correct.)
Signed,
(no longer a) Puzzled Pico Programmer