arduino / arduino/ArduinoCore-API
Ambiguous timeout return value of `Stream::parseInt` and `Stream::parseFloat`
- Dominant language
- C++
- Stars
- 306
- Forks
- 150
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the problem
The parsing functions of the `Stream` class have a timeout mechanism. If the operation does not complete prior to the expiration of the timeout, the functions return `0`:
`Stream::parseInt`:
https://github.com/arduino/ArduinoCore-API/blob/0f4e57ea193a00163ae59f0f0ff478feae7eb5db/api/Stream.cpp#L141
`Stream::parseFloat`:
https://github.com/arduino/ArduinoCore-API/blob/0f4e57ea193a00163ae59f0f0ff478feae7eb5db/api/Stream.cpp#L172
🐛 The function does not provide the user with an unambiguous indicator that the parsing failed.
### ArduinoCore-API version
Last verified with: 0f4e57ea193a00163ae59f0f0ff478feae7eb5db
### Additional context
I suggest that these functions be changed to return `(int)NAN` or `(float)NAN` on timeout.
#### Additional reports
- https://github.com/arduino/Arduino/issues/1796
- https://github.com/arduino/Arduino/issues/7177
#### Related
- https://github.com/arduino/ArduinoCore-API/issues/70
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with Stream.cpp at the parseInt and parseFloat implementations linked in the issue, then read related issue #70 and the additional Arduino reports for compatibility context. Compare timeout behavior with valid zero results and define completion as an unambiguous timeout result for both parsing functions, with behavior checked across the relevant API callers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api, embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100