- CMake 多目标工程:shs_core 静态库 + smart_home 可执行 + shs_tests 测试 - CMakePresets.json:debug/release/asan/coverage 四个预设(debug 告警即错误) - 自研零依赖测试框架 tests/framework/test_framework.h + 运行器(套件过滤、CTest 集成) - 工具:tools/header_check.sh 头文件独立编译检查(接口冻结门) - 已实现公共层:errors / string_utils / num_utils,main 启动自检 - 实测:debug 预设 0 告警、ctest 3/3 通过(45 项断言)
19 lines
521 B
C
19 lines
521 B
C
/**
|
|
* @file crc.h
|
|
* @brief CRC 校验(协议帧完整性校验)
|
|
*
|
|
* 教材对应:项目九 位运算 + 项目八 协议解析;CRC-16/MODBUS 是工业通信常用算法。
|
|
*/
|
|
#ifndef SHS_CRC_H
|
|
#define SHS_CRC_H
|
|
|
|
#include "shs/common.h"
|
|
|
|
/** CRC-16/MODBUS:多项式 0xA001(反射),初值 0xFFFF */
|
|
uint16_t shs_crc16_modbus(const uint8_t *data, size_t len);
|
|
|
|
/** CRC-8/ATM:多项式 0x07,初值 0x00(用于短帧) */
|
|
uint8_t shs_crc8(const uint8_t *data, size_t len);
|
|
|
|
#endif /* SHS_CRC_H */
|