Using an esp32 v5.5 esp-idf audio server to web client
working on an audio project where i am getting request every 256 msecs from the client for data.
i am using an i2 interrupt driven task to read samples from the i2s dma buffers so there no blocking.
The interrupt happens every 256 msecs. I am logging the interval between when i
recieve the request from the client in the handler and it alternates between 205 msecs and 307 msecs. The
interrupt and storing the data is done within the 10 msec resolution of the esp_logi statement.
The sending of the data is also within the 10 ms window of the esp_logi.
I am trying to understand why the variance in the server responding to
the request as everything else in the code is periodic and fast.
It seems like something is taking 50 msecs somewhere before it can respond to the
request so thats why i get the 307 msec delay instead of 256 msecs.
The average of the two is close to the 256 ms i would expect.
I am thinking it is something behind the scenes ie task scheduler
or a network thing.
Maybe someone has experienced this and point me in a direction.
Request times vary by 100ms on server, client send them every 256 ms
-
MicroController
- Posts: 2693
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Request times vary by 100ms on server, client send them every 256 ms
You'll have to clarify some more.
Generally, notice that logging isn't "free". Log output tends to be slow, e.g. about 11KB/s (~90ms/KB) at 115200bps, and logging calls may block until their, and all preceding, log data has made it out of the chip, or at least into the size-limited FIFO buffer.
Interval between what?I am logging the interval between when i recieve the request from the client in the handler and it alternates ...
Impossible to tell without knowing anything about your code.I am trying to understand why the variance in the server responding to the request
Generally, notice that logging isn't "free". Log output tends to be slow, e.g. about 11KB/s (~90ms/KB) at 115200bps, and logging calls may block until their, and all preceding, log data has made it out of the chip, or at least into the size-limited FIFO buffer.
Re: Request times vary by 100ms on server, client send them every 256 ms
The interval between requests from the client as seen in the server handler. The client request (at the client) are 256 msecs apart all the time. But the server sees the request (in the handler on the server) at an alternating 205 and 309 msecs. So i am expecting the server to log the request fairly uniformly time wise around the same time (256 ms) not a 50 msec difference. This is an audio app using i2s ( baby monitor so its voice audio packets at 8kHz single channel) but i am using .on_rcv callback so that I am not blocking waiting for buffers to fill up.
I am figuring out how to use wireShark to see if my network is doing anything strange to cause this. I did not post the code since it is so long. If I cant figure out whats going on in a few days I will post it or link to github.
I am figuring out how to use wireShark to see if my network is doing anything strange to cause this. I did not post the code since it is so long. If I cant figure out whats going on in a few days I will post it or link to github.
Re: Request times vary by 100ms on server, client send them every 256 ms
So the latency is coming from my home network and not the esp32 code. I figured that out by using the esp32 in ap mode and then pinged it from my pc. The numbers were much better. That isolates the esp32 stack from my home network.
Re: Request times vary by 100ms on server, client send them every 256 ms
Could also be WiFi power saving; that's not active in AP mode, but is in STA mode. I'd try disabling that.
Re: Request times vary by 100ms on server, client send them every 256 ms
I had the power savings disabled in AP mode which was not needed and but not in station mode where I needed it. That fixed a lot of the delays. I ran into another problem though. When the baby monitor was running, if I stopped and started a youtube video it would introduce a delay (only when starting the video). Youtube and baby monitor was on the same machine. I guess my internet service is not that great, lol.
Who is online
Users browsing this forum: No registered users and 2 guests
