⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crcclass.h

📁 MODBUS主、子站规约模拟程序。可以做为MODBUS规约测试的工具
💻 H
字号:
//---------------------------------------------------------------------------
#ifndef CRCClassH
#define CRCClassH
//---------------------------------------------------------------------------
typedef char BYTE1 ;
typedef unsigned char UBYTE1 ;
typedef short BYTE2 ;
typedef unsigned short UBYTE2 ;
typedef int BYTE4 ;
typedef unsigned int UBYTE4 ;

const int MAXBYTEVALUES = 256;
const int BITSPERBYTE = 8 ;

class Crc
{
public:
    Crc (   unsigned int BitCount,
          unsigned long Polynominal,
          bool Reverse,
          unsigned long Initial,
          unsigned long FinalMask) ;
    ~Crc () {}
    BYTE4  Reverse (UBYTE4 value);
    UBYTE4 value (void) const ;
    void   reset (void) ;
    void   update (const char *buffer, unsigned int length) ;
    UBYTE4 getcrc(const char *buffer, unsigned int length) ;
	bool GetReverse(void)
	{
		return FREVERSE;
	};
    _declspec( property( get=GetReverse, put=SetReverse ) ) bool REVERSE;

private:
    unsigned int    BITCOUNT;
    unsigned long   POLYNOMINAL;
    bool            FREVERSE;
    unsigned long   INITIAL;
    unsigned long   FINALMASK;
    unsigned long   mask;          
    static UBYTE4 bits [];//BITSPERBYTE * 4];
    UBYTE4 values [MAXBYTEVALUES] ;
    UBYTE4 crc_register ;
    void SetReverse(bool reverse);
    UBYTE4 ForwardTableEntry (unsigned int entryindex);
    UBYTE4 ReverseTableEntry (unsigned int entryindex);
} ;

//---------------------------------------------------------------------------
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -