8000 Transmit: add opt-in bounded retries above the driver interface by tomrford · Pull Request #83 · tomrford/gocan · GitHub
[go: up one dir, main page]

Skip to content

Transmit: add opt-in bounded retries above the driver interface - #83

#83
Merged
tomrford merged 7 commits into
mainfrom
fix/isotp-transmit-backpressure
Sep 17, 2026
Merged

tomrford merged 7 commits into
mainfrom
fix/isotp-transmit-backpressure

Conversation

@tomrford
@tomrford tomrford commented Sep 17, 2026 •
Copy link
Copy Markdown
Owner

A full native transmit queue can reject frames during otherwise valid transfers. gocan.Send(ctx, bus, frame, retryTimeout) retries only ErrTransmitQueueFull, 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 leave Update and Stop responsive.

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 to cyclic.Start and StartFunc: replace the period argument with cyclic.Config{Period: period} and set TransmitRetryTimeout to opt in. ISO-TP and XCP gain additive configuration fields.

Validation:

  • Full race suite, vet, formatting and diff checks passed locally; Windows amd64, arm64 and 386 compilation passed.
  • Independent correctness and simplification review passed. Focused lifecycle tests cover queue recovery, cancellation, definite acceptance, cyclic scheduling, stale responses, immediate replies and capture loss. The UDS lifecycle also passed 20 race-enabled repetitions.
  • No physical Vector or PCAN hardware was exercised.

@chatgpt-codex-connector
chatgpt-codex-connector Bot commented Sep 17, 2026 •
Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-17T09:37:29.006295Z ea395b8 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread xcp/command.go
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 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread isotp/transmit.go

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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@tomrford tomrford changed the title Transmit: share bounded queue retries across ISO-TP, XCP and cyclic sends Transmit: add bounded retries to Bus.Send and preserve response boundaries Sep 17, 2026
@tomrford tomrford changed the title Transmit: add bounded retries to Bus.Send and preserve response boundaries Transmit: add opt-in bounded retries above the driver interface Sep 17, 2026
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.
@tomrford
tomrford force-pushed the fix/isotp-transmit-backpressure branch from 2c55a68 to c98b2c7 Compare September 17, 2026 11:17
@tomrford
tomrford merged commit 0c68540 into main Sep 17, 2026
1 check passed
@tomrford
tomrford deleted the fix/isotp-transmit-backpressure branch September 19, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0