During the setup function, before any other initialization occurs, AR3 reads pin 11 eight times with brief delays between reads, counting how many reads return LOW. If six or more of the eight reads are LOW (majority voting), the system concludes it is running on TestSys hardware and sets a boolean flag JF_isTestSys to true. Otherwise, the flag remains false indicating FireSys hardware. This majority voting approach provides robustness against momentary electrical noise that might cause a single spurious reading.
When JF_isTestSys is true, several behavioral changes occur. All LCD I²C operations are skipped—calls to lcd.init(), lcd.clear(), lcd.setCursor(), and lcd.print() are bypassed entirely. This prevents the code from hanging while attempting to communicate with nonexistent I²C hardware, and eliminates console error messages about I²C timeouts. The cooldown detection window shortens from five minutes (FS_CD_WINDOW_MS_FIELD = 300,000 milliseconds) to one minute (FS_CD_WINDOW_MS_TESTSYS = 60,000 milliseconds). This allows test scenarios to trigger cooldown phase transitions without requiring unrealistically long hold times at reduced temperatures.
Battery voltage, when telemetry is sent to AR1, is replaced with a fixed simulated value of 12.8 volts on TestSys. This ensures that autonomous algorithm battery-based decisions can be tested without requiring a real 12-volt battery connected to the test bench. On FireSys, the actual battery voltage from AR2's sensor is used.
The latch relay coil outputs (pins 2 and 3, labeled PIN_COIL_ON and PIN_COIL_OFF) drive LEDs rather than actual relay coils on TestSys. The pulse function, which normally sends a 300-millisecond pulse to actuate a latching relay, is modified on TestSys to additionally set the LED states persistently after the pulse: if the pulse was a pump-on command, pin 3 (OFF coil) is set to LOW (energizing its LED) while pin 2 (ON coil) is set HIGH (de-energizing its LED), providing a visual indication that the pump is in the ON state. The seemingly backwards mapping (OFF coil LED on to indicate pump ON) results from the active-low LED wiring and the inverted polarity flag in the code.
This automatic hardware detection eliminates the need for conditional compilation directives, configuration file editing, or manual mode selection when moving code between test and production environments. The same compiled binary operates correctly on both hardware platforms, detecting its environment and adapting automatically.
<< Testing Infrastructure and System Validation cont | | Testing Infrastructure and System Validation cont >> |Table of Contents>
