dde27ab566
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.
52 lines
1.3 KiB
C
52 lines
1.3 KiB
C
#include "unity.h"
|
|
#include "celrs/crsf.h"
|
|
#include <string.h>
|
|
|
|
void setUp(void) {}
|
|
void tearDown(void) {}
|
|
|
|
/* CRC tests — CRC8/DVB-S2 (poly 0xD5) */
|
|
void test_crc_empty(void) {
|
|
uint8_t data[1] = {0};
|
|
TEST_ASSERT_EQUAL_UINT8(0x00, cel_crsf_crc(data, 0));
|
|
}
|
|
|
|
void test_crc_single_byte(void) {
|
|
uint8_t data[1] = {0x01};
|
|
uint8_t crc = cel_crsf_crc(data, 1);
|
|
TEST_ASSERT_TRUE(crc != 0); /* non-trivial */
|
|
}
|
|
|
|
void test_crc_known_value(void) {
|
|
/* Verify CRC is deterministic */
|
|
uint8_t data[6] = {0x10, 0x80, 0x03, 0x02, 0x80, 0x01};
|
|
uint8_t crc = cel_crsf_crc(data, 6);
|
|
TEST_ASSERT_TRUE(crc != 0);
|
|
uint8_t crc2 = cel_crsf_crc(data, 6);
|
|
TEST_ASSERT_EQUAL_UINT8(crc, crc2);
|
|
}
|
|
|
|
/* Channel helper tests */
|
|
void test_channel_clamp_min(void) {
|
|
TEST_ASSERT_EQUAL_INT16(CEL_CRSF_CH_MIN, cel_crsf_channel_clamp(0));
|
|
}
|
|
|
|
void test_channel_clamp_max(void) {
|
|
TEST_ASSERT_EQUAL_INT16(CEL_CRSF_CH_MAX, cel_crsf_channel_clamp(2048));
|
|
}
|
|
|
|
void test_channel_clamp_mid(void) {
|
|
TEST_ASSERT_EQUAL_INT16(CEL_CRSF_CH_MID, cel_crsf_channel_clamp(CEL_CRSF_CH_MID));
|
|
}
|
|
|
|
int main(void) {
|
|
UNITY_BEGIN();
|
|
RUN_TEST(test_crc_empty);
|
|
RUN_TEST(test_crc_single_byte);
|
|
RUN_TEST(test_crc_known_value);
|
|
RUN_TEST(test_channel_clamp_min);
|
|
RUN_TEST(test_channel_clamp_max);
|
|
RUN_TEST(test_channel_clamp_mid);
|
|
return UNITY_END();
|
|
}
|