Skip to content

Keep implements in automatic mode on AOG's current section demand - #106

Draft
gunicsba wants to merge 1 commit into
developfrom
fix/section-setpoint-refresh
Draft

gunicsba wants to merge 1 commit into
developfrom
fix/section-setpoint-refresh

Conversation

@gunicsba

Copy link
Copy Markdown
Contributor

Summary

Section setpoints were only sent when AOG's PGN 229 demand changed. When it didn't change, an implement in automatic ran on its own state. In a field log from 2026-10-13, a Sulky Isolink spreader in automatic spread full width for 17 and 47 minutes without receiving a single setpoint. The operator reported it as "the implement doesn't respond to commands", but no commands were being sent.

How it happens: AOG turns its own section Auto button off on every field open/close (JobNew()/JobClose()). The ISOBUS SC button keeps showing green, because it reflects the TC heartbeat. So after a field change, AOG's demand stays all off, the TC never sends anything, and the spreader switches all 12 sections on when its master switch goes on. AOG draws coverage from the implement's reported sections, so the map looks normal.

Two related gaps:

  • When the implement's master switch went on, it wasn't told the current setpoint.
  • When AOG stopped sending PGN 229 (field closed), the last demand stayed in force, even with sections on.

Changes

  • MyTCServer keeps AOG's latest demand and treats no PGN 229 for 2 s as all off. It logs both transitions.
  • Client setpoints are kept current in manual mode too.
  • The full setpoint (every condensed block, plus DDI 289 Setpoint Work State, forced) is sent:
    • right after section control is enabled (PGN 241);
    • right after the implement reports DDI 160 = automatic (e.g. switched on its own terminal);
    • right after any element's Actual Work State (DDI 141) goes from off to on while in automatic;
    • every 2 s while in automatic (SECTION_SETPOINT_REFRESH_MS).
  • Change-driven sends work as before.

Behaviour change

With section control enabled but AOG asking for no sections (Auto off, or no field open), the implement is now told off and stops working. Before, it ran on its own state. Over-application becomes under-application, which the operator notices immediately. The section demand diagnostics PR adds a log line and an AOG message that explain why.

Notes

  • Related to Switch section control on automatically when an implement connects #102 (switching to automatic on connect): with this PR, auto-on-connect is followed straight away by the current demand, instead of the implement's own state.
  • Conflicts with the TC restart recovery PR in Application::update(). Keep both sides; the resolution is in test/szello-debug.

Testing

  • Release build passes on Windows (MSVC).
  • Not yet run on a bus. Checked against the field log: the Sulky follows setpoints within ~80 ms and stays off when the master goes on after an all-off setpoint, so these sends do take effect on that implement. A debug build is going to the same machine.

🤖 Generated with Claude Code

Section setpoints were only sent when AOG's PGN 229 demand changed. Whenever
it did not change, an implement in automatic mode ran on its own state:

- After switching to automatic, nothing was sent until a section changed.
  AOG turns its own Auto button off on every field open/close, so after a
  field change its demand stays all off and the TC sent nothing at all. In
  the field a spreader in automatic spread full width for 17 and 47 minutes
  without receiving a single setpoint.
- When the implement's master switch went on, it was not told the current
  setpoint.
- When AOG stopped sending PGN 229 (field closed), the last demand stayed in
  force, even with sections on.

Now the TC keeps AOG's latest demand (all off once PGN 229 stops for 2 s),
keeps client setpoints current in manual mode too, and sends every section
setpoint plus Setpoint Work State right after section control is enabled,
after the implement reports automatic, after an implement master work state
goes on, and every 2 s while in automatic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gunicsba
gunicsba marked this pull request as draft October 14, 2026 16:01
gunicsba added a commit that referenced this pull request Nov 11, 2026
…tting is off

- After section control is switched on (connect, field open, PGN 241), send
  every condensed setpoint block and DDI 289, forced, from AOG's current
  demand (all off when none arrived in the last 2 s). Change-only sends
  never told the implement "all off" when AOG's Auto was off, so it kept
  running on its own state (ISO 11783-10 F.3.5.3 b).
- With sectionControlOnConnect off, schedule nothing on connect. Before,
  DDI 160 = 0 went out on every connect, and after one SC press or field
  open every later connect switched on.

Helpers match #106 (send_all_section_setpoint_states, forceWorkState) so
the two merge cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gunicsba added a commit that referenced this pull request Nov 11, 2026
)

* Switch section control on automatically when an implement connects

Until now an implement stayed in manual mode after connecting until the
operator pressed AOG's ISOBUS SC button, which sends PGN 241. The TC now
remembers the section control state it wants and applies it to each
client 2 s after its pool is activated: it sets the local auto flag and
writes DDI 160 when the implement declares it.

The initial state comes from the new settings.json key
"sectionControlOnConnect" (default true). Pressing AOG's button still
switches all clients and also becomes the state for implements that
connect later. The implement can still decline or go back to manual;
its DDI 160 report is followed as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Switch section control on when AOG opens a field

New sectionControlOnFieldOpen setting (default on): when AOG opens a field,
the TC switches section control on as if AOG's SC button was pressed (the
same update_section_control_enabled(true) that PGN 241 "enabled" triggers).

AOG sends the field name (PGN 0xF3) on every field open and close, and
again when the TC reconnects. Older AOG versions do not, so PGN 229
starting after a 2 s gap (AOG sends it only while a field is open) counts
as a field opening too. Both report the same opening, so it is acted on at
most once per 5 s. Field open and close are logged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep the field name branch where the guidance track code adds its own

PR #84 also adds a PGN 0xF3 branch to this if/else chain, between 0xF1 and
0xF2. In different places, the two merge without a conflict and the second
never runs. In the same place, Git reports the conflict. No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Only a new field name counts as a field opening once AOG sends one

A gap of more than 2 s in PGN 229 (AOG stalling, lost UDP packets) was
treated as a field opening and switched section control back on, even
when the operator had switched it off and the same field stayed open.
Once AOG has sent a field name (PGN 0xF3), only a change of field name
switches section control on; the PGN 229 fallback stays for AOG
versions that do not send the field name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Send the full setpoint on enable; send nothing on connect when the setting is off

- After section control is switched on (connect, field open, PGN 241), send
  every condensed setpoint block and DDI 289, forced, from AOG's current
  demand (all off when none arrived in the last 2 s). Change-only sends
  never told the implement "all off" when AOG's Auto was off, so it kept
  running on its own state (ISO 11783-10 F.3.5.3 b).
- With sectionControlOnConnect off, schedule nothing on connect. Before,
  DDI 160 = 0 went out on every connect, and after one SC press or field
  open every later connect switched on.

Helpers match #106 (send_all_section_setpoint_states, forceWorkState) so
the two merge cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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