The host end of the link: starting transactions, accepting replies and timeouts.
More...
|
| static bool | elapsed (uint32_t now, uint32_t then, uint32_t ms) |
| | Test whether a timeout has elapsed, across the 32-bit millisecond wrap.
|
| void | link_host_init (link_host_t *h, uint32_t now_ms) |
| | Set up the panel's link state.
|
| static bool | start (link_host_t *h, uint8_t op, uint8_t page, uint8_t offset, uint8_t count, const uint16_t *regs, uint32_t now_ms, link_msg_t *out) |
| | Build a request and mark it outstanding.
|
| bool | link_host_read (link_host_t *h, uint8_t page, uint8_t offset, uint8_t count, uint32_t now_ms, link_msg_t *out) |
| | Build a request.
|
| bool | link_host_write (link_host_t *h, uint8_t page, uint8_t offset, uint8_t count, const uint16_t *regs, uint32_t now_ms, link_msg_t *out) |
| | Build a write request.
|
| static bool | window_complete (const link_host_t *h) |
| | Everything in the window has arrived.
|
| static void | answered (link_host_t *h, uint32_t now_ms, bool refused) |
| | Close the outstanding request as answered.
|
| bool | link_host_accept (link_host_t *h, const link_msg_t *part, uint32_t now_ms, link_msg_t *whole) |
| | Offer one received message against the outstanding request.
|
| bool | link_host_tick (link_host_t *h, uint32_t now_ms) |
| | Time out the outstanding request, and report the link down once.
|
| bool | link_host_pending (const link_host_t *h) |
| | Whether a request is outstanding.
|
| void | link_host_abandon (link_host_t *h) |
| | Give up on the outstanding request.
|
The host end of the link: starting transactions, accepting replies and timeouts.
SPDX-License-Identifier: MIT
Offer one received message against the outstanding request.
True when the request is answered, which for a read may take several messages: whole then holds the reassembled reply. Parts that land without completing it return false and are not a fault; the caller keeps feeding until it gets true or the request times out.
Anything that does not answer the question in flight is counted as a mismatch and refused. A late reply can arrive after the panel has moved on, and accepting it would attach one page's registers to another page's request.
- Parameters
-
| h | The panel's link state. |
| part | The received message. |
| now_ms | The current time, in ms. |
| whole | Receives the reassembled reply when the request is answered. |
- Returns
- true when the request is answered, else false.
| bool link_host_tick |
( |
link_host_t * | h, |
|
|
uint32_t | now_ms ) |
Time out the outstanding request, and report the link down once.
Two clocks: a request is abandoned when it has been outstanding for LINK_HOST_TIMEOUT_MS, every time; the link is reported down when nothing has been answered for LINK_HOST_TIMEOUT_MS, once until the next reply.
True if it abandoned a request or escalated; a caller waiting for a reply stops waiting.
- Parameters
-
| h | The panel's link state. |
| now_ms | The current time, in ms. |
- Returns
- true if it abandoned a request or escalated; a caller waiting for a reply stops waiting.