hideakitai / ArtNet

Art-Net Sender/Receiver for Arduino (Ethernet, WiFi)
MIT License
257 stars 52 forks source link

Issue with millis() overflowing #127

Open audiostrom opened 1 month ago

audiostrom commented 1 month ago

I think I have spotted an issue in ArtnetSender.h What happens if millis(); overflow and now is 0 and this->last_send_times.find(dest) = 4,294,967,000 ?

void streamArtDmxTo(const String& ip, uint8_t net, uint8_t subnet, uint8_t universe, uint8_t physical)
    {
        Destination dest {ip, net, subnet, universe};
        uint32_t now = millis();
        if (this->last_send_times.find(dest) == this->last_send_times.end()) {
            this->last_send_times.insert(std::make_pair(dest, uint32_t(0)));
        }
        if (now >= this->last_send_times[dest] + DEFAULT_INTERVAL_MS) {
            this->sendArxDmxInternal(dest, physical);
            this->last_send_times[dest] = now;
        }
    }

How about (not tested) if ((now - this->last_send_times[dest]) >= DEFAULT_INTERVAL_MS)

hideakitai commented 1 month ago

@audiostrom Sorry for not getting back to you sooner. This issue is one of several known problems. I have not had time to address it and have not yet been able to fix it, but I will try to do so later.

For example, in my other library, I'm using PollingTImer library like this.