Skip to content

tech(TECH-MAIN-001): runCycle(Hal*) extrait de la boucle principale - #51

Merged
arcadien merged 24 commits into
masterfrom
tech/main-cycle
Nov 7, 2026
Merged

arcadien merged 24 commits into
masterfrom
tech/main-cycle

Conversation

@arcadien

@arcadien arcadien commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Résumé

Un cycle complet (capteurs ON → mesure → émissions → capteurs OFF → hibernation) devient runCycle(Hal*) (include/main.h). main() = hal.Init() + while (1) runCycle(&hal);, exclu sous UNIT_TEST. Tout appel Hal du cycle va au hal injecté : le cycle est testable sur native. Reprend l'intention de archive/master-2026-06, réécrite sur le main.cpp actuel.

Exigences

  • TECH-MAIN-001 (nouvelle) : runCycle(Hal*), 4 envs native_cycle_* (Oregon, Oregon VCC, Lacrosse, sans protocole) + suite test_main_cycle.
  • CONF-BUILD-001 : au plus un protocole d'environnement ; les deux → #error.
  • CONF-BUILD-002 : sélection des capteurs (cumul DS18B20 + BMx280 autorisé, BH1750 indépendant).
  • CONF-BUILD-004 : LACROSSE_ID requis avec USE_LACROSSE ou USE_BH1750 → #error explicite.
  • TECH-HAL-001 / TECH-SENSOR-001 : BMx280 (driver SparkFun via TinyI2C) ne prend plus de Hal* ; il devient un objet de portée fichier (optimisation flash).

CI

  • Job natif : native_debug + 4 native_cycle_* (106 tests).
  • Vérifications compile-fail (test/compile_fail/) et variantes de capteurs (test/build_variants/).

Taille AVR (flash, octets)

Env master cette PR
robot 7612 7688 (93,8 %)
S_04 7626 7584
S_02 5354 5300
S_03 5338 5272
S_05 3982 3944
devmodule 3932 3894
SOLAR_TEST 6568 6802

RAM statique : −62 o environ (objets sur la pile), sauf +51 o là où le BMx280 passe en .bss (pic réel inchangé).

Reste à faire (hors PR)

  • Tests de cycle FUNC-X10-006/007 et FUNC-BATTERY-003 (+ texte « main() » à corriger).
  • Build AVR DS18B20 cassé sous Windows (Ds18b20.h vs ds18b20.h, casse).
  • FUNC-SENSOR-002 obsolète ; DS18B20 traite 0 °C comme une erreur ; flags morts dans S_05/devmodule.
  • Pic de pile AVR non mesuré (robot, S_04).

Test plan

  • CI : 106 tests natifs, compile-fail, variantes, 7 builds AVR, clang-format 18.1.8
  • Validation banc : un cycle complet sur robot et S_04

🤖 Generated with Claude Code

arcadien and others added 24 commits November 7, 2026 18:19
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…envs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add test_main_cycle suite (5 tests) and four native_cycle_* envs
(oregon, oregon_vcc, lacrosse, x10) building src/ with UNIT_TEST and
SLEEP_TIME_IN_SECONDS=0; native_debug ignores the suite. TDD red: fails
with "main.h: No such file or directory".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rf LED calls

x10rf::SendCommand drives the LED itself, so the reference sequence is now
recorded on a CycleSpyHal, and transmissions are counted as
LedOff+Delay30ms pairs (one per TRANSMIT_WITH_LED) instead of LedOn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One cycle is now runCycle(Hal *hal), declared in include/main.h. Encoders
and sensor wrappers are built inside it from the injected hal;
TRANSMIT_WITH_LED and SerialPrintInfo use it too. lowBattery and
batteryVoltageInMv are locals. main() (hal.Init(); while(1) runCycle(&hal))
and the global hal are compiled out under UNIT_TEST.

AVR size, flash before -> after (static RAM):
  S_02       5354 -> 5368 (+14)   RAM 124 -> 62
  S_03       5338 -> 5438 (+100)  RAM 120 -> 58
  S_04       7626 -> 7876 (+250, 96.1%)  RAM 124 -> 62
  S_05       3982 -> 3992 (+10)   RAM 120 -> 58
  robot      7612 -> 8000 (+388, 97.7%)  RAM 120 -> 58
  SOLAR_TEST 6568 -> 6802 (+234)  RAM 107 -> 58
  devmodule  3932 -> 3962 (+30)   RAM 120 -> 58
Static RAM drop is objects moving to the stack; peak stack not measured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_main_cycle only runs in the native_cycle_* envs (native_debug
ignores it), so the native job now tests all five envs.

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

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ke no Hal*

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

BMx280 delegates all hardware access to the SparkFun driver, so it takes
no Hal* (TECH-HAL-001). It is a file-scope object in src/main.cpp: built
per cycle in ReadEnvironment it cost ~300 B flash.

Flash / RAM (static), bytes, HEAD before -> after:
| env        | flash before | flash after | RAM before | RAM after |
|------------|-------------:|------------:|-----------:|----------:|
| robot      | 8000         | 7688        | 58         | 109       |
| S_04       | 7876         | 7584        | 62         | 113       |
| S_02       | 5368         | 5300        | 62         | 113       |
| S_03       | 5438         | 5272        | 58         | 109       |
| S_05       | 3992         | 3944        | 58         | 109       |
| devmodule  | 3962         | 3894        | 58         | 109       |
| SOLAR_TEST | 6802         | 6802        | 58         | 58        |

The +51 B static RAM is the BME280 object moving from the stack to .bss
(no net change in peak RAM use).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arcadien
arcadien merged commit 7a54e80 into master Nov 7, 2026
10 checks passed
@arcadien
arcadien deleted the tech/main-cycle branch November 7, 2026 19:01
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