arduino / arduino/ArduinoCore-API

Ambiguous timeout return value of `Stream::parseInt` and `Stream::parseFloat`

未关闭
#88 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
C++
星标
306
派生
150
PR 合并指标
30 天内没有已合并 PR

描述

### 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

贡献指南

这个仓库没有索引到贡献指南

调研方向

从 issue 中链接的 Stream.cpp 里的 parseInt 和 parseFloat 实现开始,然后阅读相关 issue #70 以及其他 Arduino 报告,以了解兼容性背景。将 timeout 行为与有效的零结果进行比较,并将两个解析函数的完成定义为明确无歧义的 timeout 结果,同时检查相关 API 调用方中的行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
cpp
领域
api, embedded-iot
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。