Skip to content

Credit a restored control function for the address claim that restored it - #17

Draft
Arjan-Woltjer wants to merge 4 commits into
Open-Agriculture:mainfrom
Arjan-Woltjer:fix-restore-cf-liveness-flag
Draft

Credit a restored control function for the address claim that restored it#17
Arjan-Woltjer wants to merge 4 commits into
Open-Agriculture:mainfrom
Arjan-Woltjer:fix-restore-cf-liveness-flag

Conversation

@Arjan-Woltjer

Copy link
Copy Markdown

Mirror of AgIsoStack-plus-plus#718 for this fork. Same one-line fix; the surrounding code differs because that repo's main has since refactored this function, so the change is ported rather than cherry-picked.

The bug

update_address_table()'s restore branch returns a previously-pruned control function to controlFunctionTable because it has just announced its address — but never sets claimedAddressSinceLastAddressClaimRequest on it. The CF therefore re-enters the table already eligible for pruning, and prune_inactive_control_functions() evicts it again on the very next roll-call.

The flag is true by definition at that point: the only way to reach this branch is by processing that control function's own Address Claim message, which is exactly what the flag records. The sibling branch immediately above does precisely this for a CF already in the table.

Why it matters

It converts a single eviction into a self-sustaining cycle. While that cycle runs, the CF's table entry is repeatedly nulled, so message.get_source_control_function() stops resolving for its address and process_can_message_for_global_and_partner_callbacks() silently drops every broadcast from it — a client bound to that CF goes deaf while the device is still transmitting normally.

Found on real hardware: Teensy 4.1 running this fork at 0.1.5, Ag Leader InCommand 1200 acting as VT and TC on a New Holland tractor with the usual ECU population. Observed as unbroken is now offlinehas claimed addressis now offline churn every 1–2 seconds, sustained for 300+ seconds, on a bus issuing address-claim roll-calls roughly every 3 seconds.

Full analysis and field evidence: AgIsoStack-plus-plus#717.

Notes

🤖 Generated with Claude Code

ad3154 and others added 4 commits October 20, 2024 11:54
Updated AgIsoStack to 29dab887a48bb204aae983b06052d52b0f2314d5
Added a basic example showing how to receive machine speed messages.
…d it

update_address_table()'s restore branch puts a previously-pruned control
function back into controlFunctionTable because it has just announced its
address, but never sets claimedAddressSinceLastAddressClaimRequest on it. The
CF therefore re-enters the table already eligible for pruning, and is evicted
again on the very next address-claim roll-call.

That turns a single eviction into a self-sustaining cycle. Observed on real
hardware (Teensy 4.1, Ag Leader InCommand 1200 as VT/TC on a New Holland
tractor) as unbroken "is now offline" -> "has claimed address" -> "is now
offline" churn every 1-2 seconds, running for 300+ seconds, on a bus issuing
roll-calls roughly every 3 seconds. While that cycle runs, the CF's table
entry is repeatedly nulled, so get_source_control_function() stops resolving
for its address and process_can_message_for_global_and_partner_callbacks()
silently drops broadcasts from it -- taking the VT and TC clients down with
it while the device is still transmitting normally.

The flag is true by definition at this point: the only way to reach this
branch is by processing that CF's own Address Claim message, which is exactly
what the flag records.

Mirrors Open-Agriculture/AgIsoStack-plus-plus#718, which applies the same fix
to the equivalent (since-refactored) code on that repo's main branch. See
Open-Agriculture/AgIsoStack-plus-plus#717 for the full analysis.
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.

2 participants