Skip to content

v1.13.3 - Command Configuration Integration (2025-12-09)

What Changed?

This release completes Phase 2A of CommandQueue integration by connecting all configuration commands to the hardware detection system. SET_POLL_COUNT, SET_DEADTIME, and SET_STREAM commands now have real hardware effects. Input validation prevents integer overflow bugs, and the detection loop responds to all runtime configuration changes.


What's New

Main Feature: Hardware-Integrated Command Configuration

What it does: Connects Command class configuration to hardware detection and output systems. Commands like SET_POLL_COUNT now directly affect detection sampling, SET_DEADTIME enforces timing constraints, and SET_STREAM controls detection output.

How to use it:

# Set detection polling samples (1-65535)
set_poll_count 500
get_poll_count
β†’ {"type":"response","status":"ok","poll_count":500}

# Set detector deadtime (0-60000ms)
set_deadtime 100
get_deadtime
β†’ {"type":"response","status":"ok","deadtime_ms":100}

# Control detection output stream
set_stream 0          # Pause detection events
set_stream 1          # Resume detection events
get_stream
β†’ {"type":"response","status":"ok","enabled":1}

Code integration example (cosmic_detector.cpp):

// Detection now uses Command class poll_count
#if ENABLE_DEVICE_RESPONSE
  uint16_t poll_count = Command::getInstance().get_poll_count();
#else
  uint16_t poll_count = config_get_poll_count();
#endif

Input Validation & Overflow Prevention

Integer overflow fix: Commands now validate ranges before type casting:

  • SET_POLL_COUNT: 1-65535 (returns error_code=2 for out-of-range)
  • SET_DEADTIME: 0-60000ms (returns error_code=2 for out-of-range)
  • SET_STREAM: 0 or 1 only (returns error_code=1 for invalid values)

Example:

set_poll_count 100000000  # Old: 57600 (overflow)
                          # New: {"status":"error","code":2,"error_message":"Poll count out of range (1-65535)"}

Installation

Quick Start

# Get the release
git checkout v1.13.3

# Build development (CommandQueue mode)
task build

# Or build production (legacy mode)
task prod:build

# Upload to ESP32
task upload

# Monitor serial output
task monitor

What's Different from the Last Version?

βœ… Added

  • GET_POLL_COUNT command (was missing)
  • GET_DEADTIME command (was missing)
  • Input validation for SET_POLL_COUNT (prevents overflow)
  • Input validation for SET_DEADTIME (prevents overflow)
  • Hardware integration for SET_STREAM (detection output control)

πŸ”§ Changed

  • cosmic_detector.cpp: Now uses Command::getInstance().get_poll_count() when ENABLE_DEVICE_RESPONSE=1
  • main.cpp: Added stream_enabled check in detection_process() before sending events
  • stream_formatter.cpp: Added Command class integration for legacy mode compatibility
  • command_manager.cpp: Updated command count from 5 to 6 detection commands (added GET_POLL_COUNT)

πŸ› Fixed

  • Fixed missing GET_POLL_COUNT handler
  • Fixed missing GET_DEADTIME handler
  • Fixed uint16_t overflow when SET_POLL_COUNT receives large values
  • Fixed uint16_t overflow when SET_DEADTIME receives large values
  • Fixed SET_STREAM having no hardware effect (detection events always sent)
  • Fixed detection not using runtime-configured poll_count

Is It Safe to Upgrade?

Backward Compatible: Yes

  • prod:build (legacy mode): Fully backward compatible, stream flag checked in send_event()
  • dev:build (CommandQueue mode): Commands now have real hardware effects (improvement, not breaking change)
  • Detection behavior unchanged when commands not used
  • All configuration defaults match v1.13.2 behavior

Tests Passed

  • βœ… dev:build compiles successfully (323KB Flash, 8.5% RAM)
  • βœ… prod:build compiles successfully (307KB Flash, 6.9% RAM)
  • βœ… SET_POLL_COUNT 500 β†’ detection counts change to ~500 (verified on hardware)
  • βœ… SET_POLL_COUNT 100000000 β†’ returns error_code=2 (validation works)
  • βœ… SET_DEADTIME 0-60000 β†’ accepted (validation works)
  • βœ… SET_DEADTIME 100000000 β†’ returns error_code=2 (validation works)
  • βœ… GET_POLL_COUNT/GET_DEADTIME β†’ returns correct values
  • βœ… All pre-commit hooks passed

Release Details

  • Date: 2025-12-09
  • Version: v1.13.3
  • Files Changed: 5
  • src/command/poll_count.cpp (GET_POLL_COUNT, validation)
  • src/command/deadtime.cpp (GET_DEADTIME, validation)
  • src/command_manager.cpp (dispatch table)
  • src/cosmic_detector.cpp (integration)
  • src/main.cpp (stream control, includes)
  • src/stream_formatter.cpp (Command class integration)

  • Commits: 5

  • fix(command-poll-count): Implement GET_POLL_COUNT and add input validation
  • fix(command-deadtime): Add input validation for SET_DEADTIME
  • fix(cosmic-detector): Use Command class for poll_count
  • fix(detection): Integrate SET_STREAM control into detection output
  • fix(stream-formatter): Use Command class for stream_enabled

Next Steps

Phase 2B roadmap (v1.13.4):

  • Implement SET_THRESHOLD hardware integration (DAC synchronization)
  • Create unified process_commands() helper function for loop interface
  • Optimize detection_process() output formatting (avoid event_tβ†’device_response_t conversion)
  • Reorganize setup() initialization sections with clear comments
  • Consider full test coverage for CommandQueue message dispatch