arduino-managed-serial-device
arduino-managed-serial-device copied to clipboard
millis() timer overflow after 49 days of runtime
These kinds of comparisons don't allow for overflow:
commandQueue[position].delay = _delay + millis();
...
if(!processing && queueLength > 0 && commandQueue[0].delay <= millis()) {
timeout = millis() + commandQueue[0].timeout;
...
if(_timeout && (millis() > started + _timeout)) {
Admittedly this is a problem that will only occur every 49 days, but still...
See this for examples of best practices: Worried about millis() timer overflow?
Basically, you should do this instead (add a new "start" property):
command.start = millis();
command.delay = _delay;
And then this should be the check:
if (millis() - command.start >= command.delay) {
Feel free to post a pull request! In my case, im unlikely to run for longer than two hours at a time; so I'm not super worried about it.