跪求24位CRC校验的C语言程序,生成多项式g(x)=x^24+x^23+x^6+x^5+x+1

作者&投稿:杨梦 (若有异议请与网页底部的电邮联系)
发送方准备发送的信息位为1010101,采用CRC校验算法,生成多项式G(x)=X4+X3+X2+1, 求校验码,要计算过程~

你这个生成多项式写成二进制就是11101
然后跟10101010000一直异或就可以了
我VB写了个校验码计算软件,你要的话发给你

从末位开始,判断是否为X的几次幂,是就为1,否则为0.如上G(X)中有x的0次、1次和4次幂,则在对应的位置上有10011,从最后一位开始写。
有x的用1表示,没有的用0表示。
原式中最后的1相当于x的0次方。
最高位4次方有x那就是1,3次方和2次方没有就是0,1次方和0次方有x,就用1表示.合起来就是10011
上面的网友第二个G(X)=x^4+x^3+1应该是11001

long int GenerateChecksumCRC24_D32(unsigned long ulNumValues,unsigned long *pulData)
{
unsigned long i,ulData,lfsr = 0xFFFFFF;
for (i= 0x0; i < ulNumValues;i++)
{
ulData = pulData[i];
lfsr = CRC24_D32(lfsr,ulData);
}
return lfsr;
}
static unsigned long CRC24_D32(const unsigned long old_CRC, const unsigned long Data)
{
unsigned long D [32];
unsigned long C [24];
unsigned long NewCRC [24];
unsigned long ulCRC24_D32;
unsigned long int f, tmp;
unsigned long int bit_mask = 0x000001;
tmp = 0x000000;
// Convert previous CRC value to binary.
bit_mask = 0x000001;
for (f = 0; f <= 23; f++)
{
C[f] = (old_CRC & bit_mask) >> f;
bit_mask = bit_mask << 1;
}
// Convert data to binary.
bit_mask = 0x000001;
for (f = 0; f <= 31; f++)
{
D[f] = (Data & bit_mask) >> f;
bit_mask = bit_mask << 1;
}
// Calculate new LFSR value.
NewCRC[0] = D[31] ^ D[30] ^ D[29] ^ D[28] ^ D[27] ^ D[26] ^ D[25] ^
D[24] ^ D[23] ^ D[17] ^ D[16] ^ D[15] ^ D[14] ^ D[13] ^
D[12] ^ D[11] ^ D[10] ^ D[9] ^ D[8] ^ D[7] ^ D[6] ^
D[5] ^ D[4] ^ D[3] ^ D[2] ^ D[1] ^ D[0] ^ C[0] ^ C[1] ^
C[2] ^ C[3] ^ C[4] ^ C[5] ^ C[6] ^ C[7] ^ C[8] ^ C[9] ^
C[15] ^ C[16] ^ C[17] ^ C[18] ^ C[19] ^ C[20] ^ C[21] ^
C[22] ^ C[23];
NewCRC[1] = D[23] ^ D[18] ^ D[0] ^ C[10] ^ C[15];
NewCRC[2] = D[24] ^ D[19] ^ D[1] ^ C[11] ^ C[16];
NewCRC[3] = D[25] ^ D[20] ^ D[2] ^ C[12] ^ C[17];
NewCRC[4] = D[26] ^ D[21] ^ D[3] ^ C[13] ^ C[18];
NewCRC[5] = D[31] ^ D[30] ^ D[29] ^ D[28] ^ D[26] ^ D[25] ^ D[24] ^
D[23] ^ D[22] ^ D[17] ^ D[16] ^ D[15] ^ D[14] ^ D[13] ^
D[12] ^ D[11] ^ D[10] ^ D[9] ^ D[8] ^ D[7] ^ D[6] ^
D[5] ^ D[3] ^ D[2] ^ D[1] ^ D[0] ^ C[0] ^ C[1] ^ C[2] ^
C[3] ^ C[4] ^ C[5] ^ C[6] ^ C[7] ^ C[8] ^ C[9] ^ C[14] ^
C[15] ^ C[16] ^ C[17] ^ C[18] ^ C[20] ^ C[21] ^ C[22] ^
C[23];
LFSR代码示例
签名是一个多项式为x24+ x23+ x6
+ x5
+x+1的24位CRC。初始值为0xFFFFFF。
AN-1160
Rev. A | Page 7 of 8
NewCRC[6] = D[28] ^ D[18] ^ D[5] ^ D[0] ^ C[10] ^ C[20];
NewCRC[7] = D[29] ^ D[19] ^ D[6] ^ D[1] ^ C[11] ^ C[21];
NewCRC[8] = D[30] ^ D[20] ^ D[7] ^ D[2] ^ C[12] ^ C[22];
NewCRC[9] = D[31] ^ D[21] ^ D[8] ^ D[3] ^ C[0] ^ C[13] ^ C[23];
NewCRC[10] = D[22] ^ D[9] ^ D[4] ^ C[1] ^ C[14];
NewCRC[11] = D[23] ^ D[10] ^ D[5] ^ C[2] ^ C[15];
NewCRC[12] = D[24] ^ D[11] ^ D[6] ^ C[3] ^ C[16];
NewCRC[13] = D[25] ^ D[12] ^ D[7] ^ C[4] ^ C[17];
NewCRC[14] = D[26] ^ D[13] ^ D[8] ^ C[0] ^ C[5] ^ C[18];
NewCRC[15] = D[27] ^ D[14] ^ D[9] ^ C[1] ^ C[6] ^ C[19];
NewCRC[16] = D[28] ^ D[15] ^ D[10] ^ C[2] ^ C[7] ^ C[20];
NewCRC[17] = D[29] ^ D[16] ^ D[11] ^ C[3] ^ C[8] ^ C[21];
NewCRC[18] = D[30] ^ D[17] ^ D[12] ^ C[4] ^ C[9] ^ C[22];
NewCRC[19] = D[31] ^ D[18] ^ D[13] ^ C[5] ^ C[10] ^ C[23];
NewCRC[20] = D[19] ^ D[14] ^ C[6] ^ C[11];
NewCRC[21] = D[20] ^ D[15] ^ C[7] ^ C[12];
NewCRC[22] = D[21] ^ D[16] ^ C[8] ^ C[13];
NewCRC[23] = D[31] ^ D[30] ^ D[29] ^ D[28] ^ D[27] ^ D[26] ^ D[25] ^
D[24] ^ D[23] ^ D[22] ^ D[16] ^ D[15] ^ D[14] ^ D[13] ^
D[12] ^ D[11] ^ D[10] ^ D[9] ^ D[8] ^ D[7] ^ D[6] ^
D[5] ^ D[4] ^ D[3] ^ D[2] ^ D[1] ^ D[0] ^ C[0] ^ C[1] ^
C[2] ^ C[3] ^ C[4] ^ C[5] ^ C[6] ^ C[7] ^ C[8] ^ C[14] ^
C[15] ^ C[16] ^ C[17] ^ C[18] ^ C[19] ^ C[20] ^ C[21] ^
C[22] ^ C[23];
ulCRC24_D32 = 0;
// LFSR value from binary to hex.
bit_mask = 0x000001;
for (f = 0; f <= 23; f++)
{
ulCRC24_D32 = ulCRC24_D32 + NewCRC[f] * bit_mask;
bit_mask = bit_mask << 1;
}
return(ulCRC24_D32 & 0x00FFFFFF);
}

占位..等下回答


跪求24位CRC校验的C语言程序,生成多项式g(x)=x^24+x^23+x^6+x^5+x+1
NewCRC[11] = D[23] ^ D[10] ^ D[5] ^ C[2] ^ C[15];NewCRC[12] = D[24] ^ D[11] ^ D[6] ^ C[3] ^ C[16];NewCRC[13] = D[25] ^ D[12] ^ D[7] ^ C[4] ^ C[17];NewCRC[14] = D[26] ^ D[13] ^ D[8] ^ C[0] ^ C[5] ^ C[18];NewCR...

CRC原理简介
CRC即循环冗余校验码(Cyclic Redundancy Check):数据通信领域中最常用的一种差错校验码,其信息字段和校验字段长度可以任意指定,但要求通信双方定义的CRC标准一致。二、工作原理 对于工控领域,我们主要利用CRC校验来处理各种数据流的数据正确性校验。CRC原理 :在K位信息码(目标发送数据)后再拼接R位校...

mib消息包含哪些内容
MIB传输时间间隔TTI为40ms。不同于其他下行传输信道采用24位CRC校验,BCH采用16位CRC校验,为了减少CRC相关开销;BCH编码基于与PDCCH控制信道相同的1\/3速率咬尾卷积码,不采用Turbo编码是因为,BCH传输块较小。MIB总是以80ms的周期在BCH上传输,且在80ms内重复发送,具体重复的情况要依赖于SSB的配置。...

求java 解析7号信令数据数据
如果CRC校验正确,后向消息即被发送;如果校验出错,在发后向消息之前,信令点会将BIB置位以表示一个负(错误)指示。源点接受到这个负指示标志后,它会将从出错的消息序列号开始的所有消息重新传送,并且这些消息的FIB为1。LI:长度指示语,指示LI和CK之间的八位位组的数目,6bit。如果在LI之后、CRC...

智能卡门锁的技术说明
1、接触式IC卡①.选用SLE4442卡及符合ISO7816标准的其他IC卡。数据保存:10年以上。重复使用次数:10万次以上。信息容量:256字节,门锁只用了32个字节,剩余可用作一卡多用。密码长度:24位。重量:3-4KG体积:典型尺寸:240×78×17(MM)工作电源:直流6V,四节五号或七号碱性电池,可开锁一万次...

无损压缩的无损格式
AAL文件分为两部分,一部分是256k的A3plus也可以是其他的A3或A3+,另一部分是音乐的细节信息.这样对于普通索尼Walkman,就只有256K的那部分回放。只有真正支持AAL的机器,才可以播放其他的细节。 编码速度非常快的无损格式,但是压缩率就让人很失望了!该格式也是开放源码,同时支持Windows和Mac,不过...

绥德县19549681419: 求教C语言编写的CRC16的校验程序 -
滕莲咪唑: unsigned short crc_dsp(unsigned short reg, unsigned char data_crc) //reg为crc寄存器, data_crc为将要处理的8bit数据流 { unsigned short msb; //crc寄存器将移出的最高1bit unsigned short data; unsigned short gx = 0x8005, i = 0; //i为左移次数, ...

绥德县19549681419: 用C语言实现CRC编码程序 -
滕莲咪唑: #include#include "stdlib.h" unsigned int char2int(char *str) { unsigned int count=0, ret=0; for(count = 0; count>1;} return c; } void CRC(char *scode, char *p, char*g ) { unsigned int iP = char2int(p); unsigned int iG = char2int(g); unsigned int r= getR...

绥德县19549681419: 我要用C语言编写CRC16效验码.通过输入一个串然后计算出CRC16效验码.例如:输入010600001388计算得到849C -
滕莲咪唑: int cal_crc(unsigned char *ptr, unsigned char len) { unsigned char i; unsigned int crc_value =0; while(len--) { for(i=0x80; i!=0; i>>=1 ) { if (crc_value&0x8000) crc_value = (crc_value << 1) ^0x8005 ; else crc_value = crc_value << 1 ; if(*ptr&i) 另外,站长团上有产品团购,便宜有保证

绥德县19549681419: 易语言CRC16效验程序 -
滕莲咪唑: CRC校验是循环冗余校验,下面是C#的代e68a84e79fa5e9819331333366306433码. protected byte[] GetCRC(byte[] b, int offset, int len) { byte CRC16Lo = 0; byte CRC16Hi = 0; byte bytC; byte bytTreat; byte bytBcrc; for (int i = 0; i < len; i++) { ...

绥德县19549681419: 哪位高手有用C++语言编写的CRC8校验的程序 -
滕莲咪唑: unsigned int CRC8_Tab(unsigned char xdata * ucPtr, unsigned char ucLen) { unsigned char ucIndex; // CRC8校验表格索引 unsigned char ucCRC8 = 0; // CRC8字节初始化 // 进行CRC8位校验 while (ucLen --){ ucIndex = ucCRC8 ^ (* ucPtr ++); ucCRC8 = CRC8_TAB[ucIndex]; } // 返回CRC8校验数据 return (~ucCRC8); }

绥德县19549681419: 求C++中求CRC码的程序代码 -
滕莲咪唑: unsigned char crc8(unsigned char *source,unsigned int number) { unsigned int i = 0; unsigned char sumvalue = source[0]; for(i = 1; i{ sumvalue ^= source[i]; } return sumvalue; }

绥德县19549681419: CRC编码编程实验 -
滕莲咪唑: 在用C 语言编写CRC 校验码的实现程序时我们应该注意,生成多项式 对应的十六进制数为0x18005,由 于CRC 寄存器左移过程中,移出的最高位为1 时与 相异或,所以与16bit 的CRC 寄存器对应的生成多项 式的十六进制数可用0x8005 表示....

绥德县19549681419: crc校验问题 -
滕莲咪唑: 0X1021 是一个16进制数,转换为十进制为4129,二进制为00010000 00100001 存入CRC校验码中,高八位与低八位分开放,为buf[]={0X10,0X21};你要是知道CRC怎么算的,请更新问题.我回来看,交流一下.我也弄CRC校验码呢.uint crc16l(uchar *ptr,uchar len) 就是一个宏么,uchar *ptr指定数组,len是长度.你的crc算出来了?把代码发出来呗,我看看.还有CRC计算是,是整个发送的数组还是除去消息开始标识和结束标识?

绥德县19549681419: c#的crc32校验代码,急求~~~ -
滕莲咪唑: 这样修改应该会好用了.//688E8A9B加密 public static string GetCRC32(string input) { System.Text.ASCIIEncoding cvt = new System.Text.ASCIIEncoding(); byte[] bytes = cvt.GetBytes(input); int iCount = bytes.Length; // 1 0 1 0 0 1 1 1 0 0 0 1 1 0 1 ...

绥德县19549681419: 谁有c#编写的简单易懂的串口通讯代码带crc校验 -
滕莲咪唑: 通讯代码带CRC校验带详细的注释 return chs.GetString(bytes); } } //_ class Class_SerialPort { /// summary /// 从汉字转换到16进制 /// /summary /// par... CRC 高位校验码 checkCRCHig...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网