Skip to main content
5 events
when toggle format what by license comment
Jan 26, 2019 at 15:44 vote accept Bort
Jan 26, 2019 at 15:44 comment added Bort I'm accepting this answer, as it has a step-by-step and your fix example code makes minimal changes to the original. You will receive your prize in the mail shortly.
Jan 24, 2019 at 23:38 comment added NMF When there's no data available you're running in quite a tight loop, so when you think about it, it's not too much of a surprise that a newly received byte might be detected first by either of the Serial.available() calls with a similar probability.
Jan 24, 2019 at 23:29 comment added Bort Thanks for the step by step run-through, even if you saw I caught it before you posted. I'll conjure a fix tomorrow and report back. It was interesting to me at first that this race condition would happen so often, as it's two conditionals right after another, with the first being false/skipped. I thought "Hmm, there are so few executions for serial data to arrive in." but then I realized that it's because I have so little else going on in the loop. My much larger programs would be very unlikely to encounter this, and if they did, it would be ignored as a one-off error.
Jan 24, 2019 at 21:58 history answered NMF CC BY-SA 4.0