ezieragabriel / arduino

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

parseInt documentation does not state what value is returned if the read times out #1069

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use `Serial.parseInt()` in a sketch. e.g. `int value = Serial.parseInt();`
2. Don't enter a number when running the sketch. i.e. let the `parseInt()` call 
time out.
3. The value returned (in the `value` variable) will be `0`.

What is the expected output? What do you see instead?

Expect to see "If no integer value is found before the read times out a value 
of zero will be returned." on the documentation page in the "Returns" section: 
<http://arduino.cc/en/Serial/ParseInt>. See nothing about a timeout return 
value on the page.

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?

1.0.1 / NA / NA 

Please provide any additional information below.

Note in the `parseInt()` method in 
`Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Stream.cpp` 
there is the line:

  return 0; // zero returned if timeout

Original issue reported on code.google.com by follower@gmail.com on 13 Oct 2012 at 6:17

GoogleCodeExporter commented 9 years ago
Note that a fix should also be applied to the Stream::parseInt docs: 
<http://arduino.cc/en/Reference/StreamParseInt>

Original comment by follower@gmail.com on 13 Oct 2012 at 6:20

GoogleCodeExporter commented 9 years ago

Original comment by s.fitzge...@arduino.cc on 5 Jun 2013 at 5:16