arduino / arduino/ArduinoCore-API
add isFlushed() to Stream/HardwareSerial
- 主要语言
- C++
- 星标
- 306
- 派生
- 150
- PR 合并指标
- 30 天内没有已合并 PR
描述
Please add Serial.isFlushed() method for checking that all data in Tx buffer have been flushed. We need it for non-blocking Serial.write() to half duplex communication (such as RS485).
At the moment I use something like this in my non-blocking code:
```
while (Serial.availableForWrite() > 0 && ndx < sizeof(buffer)) {
Serial.write(buffer[ndx]);
ndx++;
}
if (Serial.availableForWrite() == SERIAL_TX_BUFFER_SIZE - 1 && ndx > sizeof(buffer)) {
ndx = 0;
// Disable RS485 transmit and start receiving
}
```
But Serial.availableForWrite() == SERIAL_TX_BUFFER_SIZE - 1 is not reliable for checking that Tx buffer has been flushed.
Here is an earlier PR which was never merged:
https://github.com/arduino/Arduino/pull/3737
and a similar PR for ArduinoCore-sam here:
https://github.com/arduino/ArduinoCore-sam/pull/7
I would help, but coding Arduino core is beyond my skills.
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先查看 Stream/HardwareSerial 以及 issue 中链接的早期 Arduino PRs,以了解提议的 API 和受影响的 core 实现。确认当前如何公开传输缓冲区状态,然后将完成标准定义为:Serial.isFlushed() 能可靠地报告所有传输数据都已离开缓冲区,以供 half-duplex 使用,并在相关 core 测试串行行为的地方提供相应的覆盖率。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cpp
- 领域
- api, embedded-iot
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100