My System – OpenSprinkler Unified Firmware (latest version) Buster on Raspberry Pi Zero 2W connected via wifi to my network.
I’m controlling the sprinkler valves using a simple custom pcb using the GPIO pins to control the valves.
Flow control measurement problem
While tracking down inaccurate flow rate measurements that occurred when the flow rate input exceeded 8hz I discovered a 50ms delay in the main.cpp do_loop that limited the polling capability of the flow input signal.
Using strace I discovered a 50ms delay caused by tv_usec. Tracking down tv_usec lead me to this etherport.cpp function:
// This function blocks until we get a client connected.
// It will timeout after 50ms and return a blank client.
// If it succeeds it will return an EthernetClient.
EthernetClient EthernetServer::available()
{
fd_set sock_set;
FD_ZERO(&sock_set);
FD_SET(m_sock, &sock_set);
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 50 * 1000; // 50ms
So, my question is why is this function being continuously executed each time through the do_loop?