v1.6.6 - Protocol Deduplication & Code Clarity (2025-11-19)¶
What Changed?¶
This release refactors the serial communication module to explicitly enforce protocol mutual exclusivity at compile time. The firmware eliminates confusing backward-compatibility code that suggested runtime protocol switching while the build system already enforced mutual exclusivity. The refactoring improves code clarity and maintainability with zero functional changes.
What's New¶
Main Feature: Protocol Deduplication Refactoring¶
What it does:
Reorganizes the serial communication code to make it crystal clear that legacy 3-byte protocol and text command protocol cannot coexist. Protocol-specific code is now wrapped in conditional compilation blocks (#if !ENABLE_TEXT_COMMANDS and #if ENABLE_TEXT_COMMANDS), making the architecture explicit and preventing accidental protocol mixing.
How to use it: No changes to how you use the firmware. Both build profiles work exactly as before:
# Production build (legacy 3-byte protocol only)
task prod:build && task prod:upload
# Development build (text commands only)
task dev:build && task dev:upload
# Monitor serial communication
task monitor
Code example (shows the improvement):
Before (confusing):
#if ENABLE_TEXT_COMMANDS
bool text_command_processed = process_text_commands();
#else
bool text_command_processed = false;
#endif
#if !ENABLE_TEXT_COMMANDS
if (!text_command_processed && serial_command_available()) {
// Legacy protocol - but the flag suggests both are evaluated!
}
#endif
After (clear):
#if ENABLE_TEXT_COMMANDS
// TEXT COMMAND PROTOCOL (development/testing mode)
process_text_commands();
process_queued_text_command();
#else
// LEGACY 3-BYTE DAC PROTOCOL (production mode)
if (serial_command_available()) {
// Legacy protocol handling
}
#endif
Installation¶
Quick Start¶
# Get the release
git checkout v1.6.6
# Build
task build
# Upload
task upload
# Check it works
task monitor
What's Different from the Last Version?¶
β Added¶
- Enhanced documentation in CLAUDE.md clarifying protocol mutual exclusivity
- Explicit section comments in source code labeling shared vs. protocol-specific implementations
π§ Changed¶
- Reorganized
include/serial_communication.hwith clear conditional compilation blocks for protocol separation - Restructured
src/serial_communication.cppto gate protocol-specific state and functions with#ifdirectives - Simplified
src/main.cppmain loop logic by removing confusingtext_command_processedflag - Replaced multi-condition protocol checking with single-path selection using build-time conditional compilation
π Fixed¶
- Removed dead code path that suggested both protocols could coexist at runtime (they cannotβmutual exclusivity is enforced at compile time)
Is It Safe to Upgrade?¶
Backward Compatible: Yes
- No breaking changes to public APIs
- No functional changes to either protocol
- Existing firmware behavior identical before and after upgrade
- Both build profiles (production and development) work exactly as before
- Safe to upgrade in production; no risk of serial communication issues
Tests Passed¶
- β
Production build (
task prod:build) compiles without errors - β
Development build (
task dev:build) compiles without errors - β No linker errors or undefined references in either build
- β
Serial communication verified functional via
task monitor - β Protocol selection logic verified in both build profiles
- β Code review confirmed all protocol-specific functions properly gated
Release Details¶
- Date: 2025-11-19
- Version: v1.6.6
- Files Changed: 6 (header, implementation, main loop, documentation)
- Commits: 4 refactoring commits + 1 version bump commit
refactor: deduplicate protocol conditional compilation(header reorganization)refactor: deduplicate protocol implementations(cpp reorganization)refactor: simplify main loop protocol selection(main.cpp cleanup)docs: update CLAUDE.md with protocol mutual exclusivity(documentation)bump: version 1.6.5 β 1.6.6 [skip ci](version bump)
Next Steps¶
See REFACTORING_ROADMAP.md for the overall firmware modernization plan. Protocol deduplication (Phase A) is now complete. Upcoming phases include:
- Phase B: Error message and response text duplication (reducing redundant status strings)
- Phase C: Text command parsing refactoring (improving command handler efficiency)
- Phase D: Advanced optimization opportunities
For development guidance, see CLAUDE.md and the project hardware documentation.