Repository navigation
Transmit: add opt-in bounded retries above the driver interface - #83
#83Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea395b8ae8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| client.retaining = true | ||
| client.mu.Unlock() | ||
| if err := client.bus.Send(ctx, frame); err != nil { | ||
| if err := gocan.Send(ctx, client.bus, frame, client.config.TransmitRetryTimeout); err != nil { |
There was a problem hiding this comment.
Refresh the XCP receive frontier before each retry
When the native queue remains full, the cursor captured at command.go:49-52 can be up to TransmitRetryTimeout old by the time this call accepts the command. A delayed positive or negative XCP response recorded during that retry interval is therefore consumed as the response to the newly accepted command, even though it arrived before the command was transmitted; because XCP responses contain no command identifier, this can silently associate stale data with the current operation. The receive frontier needs to be refreshed immediately before every native attempt that might accept the command.
Useful? React with 👍 / 👎.
|
|
||
| func (link *Link) sendFrame(ctx context.Context, frame gocan.Frame) error { | ||
| return link.bus.Send(ctx, frame) | ||
| return gocan.Send(ctx, link.bus, frame, link.transmitRetryTimeout) |
There was a problem hiding this comment.
Preserve the ISO-TP receive boundary during first-frame retries
When the first frame of Begin or a segmented Send is rejected as queue-full, this retry can delay acceptance for up to a second while the receive cursor remains at the frontier captured by startReception(true). Traffic arriving on the receive ID during that interval is consequently treated as post-request traffic: Begin.Next can return a stale payload, and segmented transmission can consume a stale Flow Control frame before the peer has seen the retried First Frame. The first-frame retry path must re-establish the receive frontier immediately before each attempt that may be accepted.
Useful? React with 👍 / 👎.
gocan.Send is the single place that rejects a negative retry timeout; the isotp, xcp and cyclic constructors no longer duplicate the check, and Send drops its nil-bus guard. The ISO-TP retry timeout lives on the shared transmitter instead of separate Link and Functional fields, and transmit's flag is named for what it does. Comments explain the timer/expiry race in Send and the stop-cause mapping in cyclic. The UDS lifecycle test asserts the exact accepted-transmission cursor. The ISO-TP backpressure test rejects every frame once instead of at magic offsets, derives its frame count, and drops default-timeout and functional plumbing checks already covered by the gocan.Send test. The XCP test keeps one exhaustion check.
gocan.Send's own test now lets the retry budget expire, so the ISO-TP and XCP integration tests drop their copies of that check. The ISO-TP transfer no longer injects a stale Flow Control: the Begin fence check that follows exercises the same cursor repositioning.
2c55a68 to
c98b2c7
Compare
A full native transmit queue can reject frames during otherwise valid transfers.
gocan.Send(ctx, bus, frame, retryTimeout)retries onlyErrTransmitQueueFull, preserving the same frame until acceptance. Zero makes one attempt; a positive duration bounds waiting from the first rejection. Caller cancellation, earlier deadlines and bus closure stop retries. Accepted native outcomes remain definite even if cancellation occurs during the native call.Physical and functional ISO-TP, XCP and cyclic transmission expose
TransmitRetryTimeout; zero disables retries consistently. XCP starts response timing after acceptance. Cyclic retries stop at the next scheduled occurrence after frame generation, keep that occurrence's frame snapshot, and leaveUpdateandStopresponsive.ISO-TP and XCP locate the accepted TX capture record before receiving. This excludes stale responses and Flow Control recorded during queue rejection while preserving immediate replies recorded before Send returns. Missing TX records report capture loss, and XCP retains uncertainty about an accepted command. Each protocol endpoint must exclusively own its transmit ID during an operation.
Bus.Send(ctx, frame)and all drivers retain their existing single-attempt interface and implementation. J1939 is unchanged. The public API migration is limited tocyclic.StartandStartFunc: replace the period argument withcyclic.Config{Period: period}and setTransmitRetryTimeoutto opt in. ISO-TP and XCP gain additive configuration fields.Validation: