df3d399610
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.
25 lines
974 B
C
25 lines
974 B
C
#pragma once
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include "celrs/crsf.h"
|
|
|
|
/* Incremental CRSF frame parser for streaming byte data.
|
|
* Accepts raw bytes and extracts complete frames as they arrive. */
|
|
typedef struct cel_crsf_stream cel_crsf_stream;
|
|
|
|
/* Create a new stream reader. Returns NULL on allocation failure. */
|
|
cel_crsf_stream* cel_crsf_stream_create(void);
|
|
|
|
/* Free the stream reader. */
|
|
void cel_crsf_stream_destroy(cel_crsf_stream* stream);
|
|
|
|
/* Feed raw bytes into the stream. Returns the number of complete frames
|
|
* parsed into out[]. out must have space for at least out_capacity frames.
|
|
* Returns -1 on error. Frames that fail CRC validation are discarded. */
|
|
int cel_crsf_stream_feed(cel_crsf_stream* stream, uint8_t const* data,
|
|
size_t len, cel_crsf_frame* out,
|
|
size_t out_capacity);
|
|
|
|
/* Reset the internal buffer (discard any partial frame). */
|
|
void cel_crsf_stream_reset(cel_crsf_stream* stream);
|