📄 crc16.h
字号:
// Crc16.h#ifndef USHORT#define USHORT unsigned short#endif#ifndef BYTE#define BYTE unsigned char#endif#ifndef TRUE#define TRUE (1)#endif#ifndef FALSE#define FALSE (0)#endif#define BOOL int/** This class provides functions for computing 16-bit CRC values.* It implements both a slow bit-at-a-time method and a table-driven* method. The simple method was implemented as a way of verifying* that the optimized table-method works. ** POPULAR POLYNOMIALS** @li CCITT: x^16 + x^12 + x^5 + x^0 (set m_Polynomial to 0x1021)* @li CRC-16: x^16 + x^15 + x^2 + x^0 (set m_Polynomial to 0x8005)*** REFLECTED INPUT/CRC** Reflected input and reflected CRC is common with serial interfaces.* This is because the least-significant-bit is typically transmitted * first with serial interfaces.*/class CCrc16{public: CCrc16(); USHORT ReverseBits( USHORT x ); BYTE ReverseBits( BYTE b ); void SimpleNextByte( BYTE b ); USHORT SimpleComputeBlock( BYTE* data, int length ); USHORT SimpleGetCrc(); USHORT CreateTableEntry( int index ); void CreateTable(); USHORT ComputeCrcUsingTable( BYTE* data, int length ); USHORT m_Crc; USHORT m_ResetValue; USHORT m_Polynomial; BOOL m_Reflect; BOOL m_ReflectCrc; USHORT m_CrcXorOutput; USHORT m_Table[256];};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -