Sunday, November 7, 2021

Dealing with spurious input with first read on Arduino

 RESOLUTION DISCOVERED BY TRIAL AND ERROR

I determined that as short as a one millisecond delay via the delay(1) command will cure the issue I see, where the Serial.available() reports data in the buffer and immediately after the Serial.readBytes pulls spurious content. Not sure if it is just the time spent or it depends on the delay implementation allowing interrupts to occur but this reliably solves the problem. 

No comments:

Post a Comment