You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
724 B

#pragma once
#include <stdbool.h>
#include <stdint.h>
/**
* @brief 生成CRC16校验码
*
* @param puckMsg 数据指针
* @param usDataLen 数据长度(不包含CRC16)
* @return uint16_t
*/
uint16_t modbus_gen_crc16(uint8_t *puckMsg, uint8_t usDataLen);
/**
* @brief 将CRC16校验码添加到数据包中
*
* @param puckMsg 数据指针,数据中预留两个位置给CRC16
* @param packetlen 数据长度
*/
void modbus_pack_crc_to_packet(uint8_t *puckMsg, uint8_t packetlen);
/**
* @brief 检查CRC16校验码
*
* @param message 数据指针
* @param length 数据长度(包含CRC16)
* @return true 校验成功
* @return false 校验失败
*/
bool modbus_checkcrc16(uint8_t *message, uint8_t length);