Rename library targets from celrs_* to cel* (celcrsf, celserial,
cellogger, cellog) and add cel:: namespace aliases. Add cel::cel
umbrella target that links all core libraries.
Add ENABLE_TESTING option (default ON) to gate Unity/CMock fetch
and test targets for downstream consumers.
cel_crsf_build_rc_frame tagged RC channel frames with 0x01,
which is not a valid CRSF frame type. The TX module's CRSF
parser never recognized these as channel updates, so it had
no RC data to forward over RF and the receiver could never
report link quality.
Use CEL_CRSF_TYPE_RC_CHANNELS (0x16), the spec-correct RC
Channels Packed type. Drop the bogus 0x01 enum value.
CRSF battery frame is big-endian: voltage(u16 BE 0.1V),
current(u16 BE 0.1A), capacity(u24 BE mAh), remaining(u8 %).
Previous code read little-endian with wrong byte count (7 vs 8)
and wrong scaling (/1000 vs /10), producing 9.98V for a 1S battery.
Enumerate parameters until TX Power entry is found, match
requested mW against TEXT_SELECT options, and write the
selected option index.
Added:
- str_contains_ci() for case-insensitive substring matching
- is_power_param() to detect power-related parameters
- match_power_option() to find mW in option strings
- 4 new tests: null port, frame roundtrip, success, not found
Ping sends DEVICE_PING frame and waits for DEVICE_INFO response.
Read sends PARAM_READ frame and waits for matching PARAM_ENTRY.
Both use cel_crsf_stream_feed() with a clock-based timeout loop.
Parse PARAM_ENTRY payload into cel_crsf_param struct. Handles
TEXT_SELECT with options string and UINT8/INT8 with min/max/default/
value fields. Respects hidden flag (bit 7 of type byte). Truncates
name and options to buffer limits.
Implement cel_serial_find_elrs_port() which enumerates serial ports
and matches descriptions against ELRS-related keywords (CP210, CH340,
FTDI, etc.). Implement cel_serial_open_probe() to try multiple baud
rates in order.
Add cel_serial_platform_get_description() for Windows (SetupAPI)
and POSIX (sysfs fallback). Wire setupapi into the Windows build.
Update serial tests with CMock expectations for the new functions.
cel_crsf_telemetry_parse() decodes link stats, battery, heartbeat,
and airspeed frames. Updated cel_telem_battery and cel_telem_airspeed
structs to use uint16_t values matching CRSF protocol format.
cel_crsf_channel_us_to_val() and cel_crsf_channel_val_to_us()
convert between microseconds (988-2012) and 11-bit values (172-1811)
with rounding. cel_crsf_channel_default() fills safe/disarmed values.
cel_crsf_frame_parse() parses ELRS USB format frames:
[addr][length][type][payload...][crc]
cel_crsf_stream_* provides incremental parsing from a byte
stream: skips invalid sync bytes, discards bad CRC frames,
buffers partial frames across feed calls.
The old [0xC8][dest][src][type][size][payload][crc] format was never
used with real hardware. Remove cel_crsf_frame_legacy, *_legacy()
functions, and update tests/tools accordingly.
Switch CRC from CCITT (0x07) to DVB-S2 (0xD5) to match ELRS.
Adopt ELRS USB frame format: [addr][length][type][payload][crc].
Update frame type constants to match current ELRS protocol values.
New skeleton modules (stub implementations with TODO comments):
- crsf_telemetry.h/.c: telemetry decoders (GPS, battery, link..)
- crsf_stream.h/.c: incremental streaming frame reader
- crsf_param.h/.c: parameter protocol (read/write/set_power)
Retained old frame format as *_legacy functions for backward
compatibility with existing telemetry tool and tests.
Add cel_serial_find_elrs_port() and cel_serial_open_probe()
stubs to serial module for port auto-detection and baud probing.
Add cel_serial_platform_open/close/read/write/flush for
Windows using CreateFileA, DCB for baud/8N1, and
SetCommTimeouts for non-blocking reads.
serial.c now delegates all operations to the platform
backend via a cel_serial_platform_handle, and
test_serial.c mocks that backend with CMock.
Drop timeout_ms; read now returns immediately with whatever
data is available (0 if none), so callers don't block the rest
of their loop waiting on serial I/O.
telemetry's poll loop now sleeps interval_ms itself between
empty reads via a small sleep_ms helper.
test_serial mocked log_write.h, which serial.c never calls.
Split celrs_serial into celrs_serial (platform-agnostic logic)
and celrs_serial_platform (real Win/POSIX backend), matching
the celrs_logger/celrs_log_write split.
test_serial now mocks celrs/platform/serial_internal.h and
links only celrs_serial, so the list-ports tests verify the
max_ports clamping and pass-through logic without hitting the
real registry or /dev.
Implement cel_serial_list_ports/cel_serial_free_ports with
platform backends: Windows reads HKLM\HARDWARE\DEVICEMAP\
SERIALCOMM (fast, single registry read), POSIX scans /dev for
ttyUSB*/ttyACM*.
telemetry tool gains --list, --port, and --baudrate flags;
baud rate was previously hardcoded to 400000. Rename the
tool_telemetry CMake target to telemetry.
Fix test_free_ports_zero_count, which passed a stack array to
cel_serial_free_ports (which calls free() on it), corrupting
the heap.