Since _gotLastPacket is a multi-byte value, the process of loading it into registers may be interrupted by a UART interrupt, which may change the value of _gotLastPacket. If this happens, the value returned by noDataSince() will be effectively random and may incorrectly trigger timeouts.
Fix this by disabling interrupts around the load, making it atomic.
This is not just a theoretical problem - I actually hit this pretty often with a DMX transmitter that sends very small packets in very quick succession.
Since _gotLastPacket is a multi-byte value, the process of loading it into registers may be interrupted by a UART interrupt, which may change the value of _gotLastPacket. If this happens, the value returned by noDataSince() will be effectively random and may incorrectly trigger timeouts.
Fix this by disabling interrupts around the load, making it atomic.
This is not just a theoretical problem - I actually hit this pretty often with a DMX transmitter that sends very small packets in very quick succession.