feat: adopt ELRS USB CRSF frame format, add skeleton modules
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.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
add_executable(telemetry telemetry.c)
|
||||
target_include_directories(telemetry PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||
target_compile_features(telemetry PRIVATE c_std_23)
|
||||
target_link_libraries(telemetry PRIVATE celrs_crsf celrs_serial celrs_serial_platform celrs_logger celrs_log_write)
|
||||
target_link_libraries(telemetry PRIVATE celrs_crsf celrs_serial
|
||||
celrs_serial_platform celrs_logger celrs_log_write)
|
||||
|
||||
+10
-6
@@ -106,12 +106,16 @@ int main(int argc, char const* argv[]) {
|
||||
snprintf(msg, sizeof(msg), "Connected to %s (%d baud)", port_path, baud_rate);
|
||||
cel_log_info(msg);
|
||||
|
||||
/* Send heartbeat to establish CRSF link */
|
||||
/* TODO: update for new ELRS frame format.
|
||||
* New format uses cel_crsf_build_rc_frame() and cel_crsf_stream_feed(). */
|
||||
|
||||
/* Send heartbeat to establish CRSF link (legacy format) */
|
||||
uint8_t hb_payload[2] = {CEL_CRSF_ADDRESS_TBS_GROUND_STATION, 0x01};
|
||||
uint8_t hb_frame[256];
|
||||
size_t hb_len = cel_crsf_frame_build(hb_frame, CEL_CRSF_ADDRESS_FC_BROADCAST,
|
||||
size_t hb_len = cel_crsf_frame_build_legacy(hb_frame,
|
||||
CEL_CRSF_ADDRESS_FC_BROADCAST,
|
||||
CEL_CRSF_ADDRESS_TBS_GROUND_STATION,
|
||||
CEL_CRSF_FRAMETYPE_HEARTBEAT, hb_payload, 2);
|
||||
0x03, hb_payload, 2);
|
||||
cel_serial_write(port, hb_frame, hb_len);
|
||||
|
||||
printf("RX\tLINK\tSNR\tTXP\tRSSI_RC\n");
|
||||
@@ -127,13 +131,13 @@ int main(int argc, char const* argv[]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
cel_crsf_frame frame;
|
||||
if (cel_crsf_frame_parse(&frame, buf, n) != 0) {
|
||||
cel_crsf_frame_legacy frame;
|
||||
if (cel_crsf_frame_parse_legacy(&frame, buf, n) != 0) {
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (frame.type != CEL_CRSF_FRAMETYPE_PACKET_LINK_TELEMETRY) {
|
||||
if (frame.type != 0x02) {
|
||||
continue; /* skip non-telemetry frames */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user