leo25 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

serialEvent easier-to-understand model #626

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What change would like to see?

This patch changes the meaning of serialEvent from "new data has arrived since 
the last call to serialEvent" to "data is currently available".

It also includes Michael Smith's suggestion to fix issue 625.

Why?

The current model is not very convenient for 2 reasons.

1: You must consume all available data.  Because the meaning is "new data since 
the last call", if you don't use all the data, the remaining data you didn't 
use isn't "new" next time.  You don't get another call, unless even more new 
data arrives.

2: You must be prepared for no data.  The "new data since the last call" might 
have arrived shortly after the call was made, just as your code was getting 
started.  Even though you already read that byte, it's still technically "new" 
the next time, because it arrived after the call has already been made.

Would this cause any incompatibilities with previous versions?  If so, how
can these be mitigated?

Should be compatible, since it only removes restrictions on how serialEvent 
coding practices.

Original issue reported on code.google.com by paul.sto...@gmail.com on 6 Sep 2011 at 1:25

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 7 Sep 2011 at 9:43

GoogleCodeExporter commented 9 years ago
https://github.com/arduino/Arduino/commit/ab36bd5dbbc0ace7ca6ef021c537a0759ff6e6
a3

Original comment by dmel...@gmail.com on 7 Sep 2011 at 9:48

GoogleCodeExporter commented 9 years ago
Issue 625 has been merged into this issue.

Original comment by dmel...@gmail.com on 8 Sep 2011 at 8:31