proposal: rework timeouts, StreamDevices and DatagramDevices
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 8/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- embedded-iot
Hướng nghiên cứu
This is a design proposal, not a patch: it asks whether the StreamDevice and DatagramDevices interfaces should be merged, with read/write treating timeouts as non-errors and read_all/write_all treating them as errors. Start by reading the three comments to see whether maintainers reached a decision, and check the interface definitions the issue refers to. Done means a maintainer-agreed interface design, which should come before any code.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary:
-
Change the default timeout behavior in protocols that behave like streams
-
Analyze ambiguity between the current Datagram and StreamDevices interfaces
-
Extra case: Analyze the use case of drivers exposing generic interfaces
How a timeout can turn a stream into a datagram
A stream represents a communication channel with no predefined size.
Because of this, a timeout should not be treated as an error by default — it’s expected that a device might not send an entire buffer at once, or that a receiver might not always have enough incoming data to fill its read buffer.
However, the way we currently handle timeouts in most UART HALs treats a timeout as a failed transmission of a fixed-size buffer in single transaction, effectively turning the stream into a datagram-like operation.
This raises an interesting question:
Is UART really a StreamDevice?
Streams often use UART as their canonical example, since UART is a very common way to perform raw communication between two controllers.
But thinking more deeply — what prevents a fixed-size protocol from using UART?
Nothing. It’s perfectly valid (even if less common in some designs) to implement length-defined packet protocols over UART.
That means StreamDevice has an edge case where it behaves like a datagram.
But then, what are the edge cases for Datagram?
Is a datagram also a kind of stream?
By analogy, datagram interfaces are typically represented by I2C or SPI, which are usually used for fixed-size packet transfers.
And that’s true — to some extent.
These buses are very common in simple modules where communication rules are rigidly defined, and a write timeout or failed full transfer is indeed an error.
But both I2C and SPI can also be used in a stream-like context, especially SPI, which is often used for raw controller-to-controller communication (similar to USART).
I2C as a special case:
In a host → device transaction, the device can send a NACK to indicate it no longer wants to receive data — this is valid behavior.
In a device → host transaction, the specification requires the device to send 0xFF if it has no more data to transmit; This means that a reader with an arbitrary buffer length does not generate an error, which is problematic for streams: here, 0xFF is ambiguous, as it could be either valid data or a placeholder.
Despite this, REPEATED START, makes it much closer to stream-like behavior over a datagram, And there are also cases of
some I2C modules — especially those that also support SPI — to typically provide a burst read/write function, allowing the host to read or write N bytes sequentially (as long as a certain limit is not exceeded), edge-case of stream-like behavior on I2C.
So, even protocols usually treated as datagram-based have situations where they behave like streams.
In other words:
Anything that can be a stream can also behave like a datagram —
but not everything that’s a datagram can behave like a stream.
Why separate them, then?
If the distinction between stream and datagram depends mostly on how timeouts and buffer sizes are handled, we might not need two separate interfaces at all.
By defining methods like read_all and write_all, we can express both behaviors cleanly:
write/read— Timeout, NACK or any EOF is not an error → behaves like a streamwrite_all/read_all— Timeout, NACK or any early EOF is an error → behaves like a datagram
- Ngôn ngữ chính
- Zig
- Star
- 2.3k
- Fork
- 198
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 37
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ZigEmbeddedGroup/microzig
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
ZigEmbeddedGroup/microzig#1086 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 69/100
ZigEmbeddedGroup/microzig#1085 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
ZigEmbeddedGroup/microzig#1061 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
ZigEmbeddedGroup/microzig#1059 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
regz: AVR peripherals generated at address 0 when the register-group name matches the module (ATDF)Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
ZigEmbeddedGroup/microzig#1072 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ZigEmbeddedGroup/microzig
Issue tương tự
-
area: core priority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
EPFL-TOP/smart-microscope-control#132 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
scope:mqtt-bridge type:feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
bvis/aegis-hass#588 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
integration: homewizard
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
home-assistant/core#186409 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
joleys/niko-home-control-II#321 ·