CRC校验问题,急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?急?(100分)

  • 主题发起人 主题发起人 bjluoagzn
  • 开始时间 开始时间
B

bjluoagzn

Unregistered / Unconfirmed
GUEST, unregistred user!
[h1][red]
代码:
void computeCRC(IN unsigned char* pInBuffer, IN unsigned short length, OUT unsigned char *pTransmitFirst, OUT unsigned char *pTransmitSecond)
函数功能:
	计算TYPEB的数据帧的CRC

参数说明:
    pInBuffer    指向待处理的数据缓冲区
    length       数据长度 ,不计入crc本身的2字节
    pTransmitFirst       指向要首先发送的CRC字节(低字节)
    pTransmitSecond      指向第二个CRC字节(高字节)
返回值:
	无

备注:

void computeCRC(unsigned char* pInBuffer,  unsigned short length, unsigned char *pTransmitFirst, unsigned char *pTransmitSecond)
{
	unsigned char ch;
	unsigned short wCrc;
    unsigned short temp1,temp2,temp3,temp4;
	wCrc = 0xFFFF; // ISO/IEC 13239 (formerly ISO/IEC 3309)

	do {
		ch = *pInBuffer++;
		ch = (ch^(unsigned char)(wCrc & 0x00FF));
		ch = (ch^(ch<<4));
        temp1=(wCrc >> 8);
        temp3=((unsigned short)ch << 8);
        temp4=((unsigned short)ch<<3);
        temp2=((unsigned short)ch>>4);
        wCrc=temp1 ^temp2^temp3^temp4;
	} while (--length);

	wCrc = ~wCrc; // ISO/IEC 13239 (formerly ISO/IEC 3309)
	*pTransmitFirst = (unsigned char)(wCrc & 0xFF);
	*pTransmitSecond = (unsigned char)((wCrc >> 8) & 0xFF);
	return;
}
//=======================================================================
//源文件结束

能否帮我把上面的C语言程序转换成Delphi.谢谢
能否帮我把上面的C语言程序转换成Delphi.谢谢
能否帮我把上面的C语言程序转换成Delphi.谢谢
能否帮我把上面的C语言程序转换成Delphi.谢谢
[/red][/h1][:(!]
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1385808
 
CRC校验很多,可它算出来&quot;05 fe 00&quot;的校验值是&quot;6919&quot;,我怎么算也不对呀
 
你就把他用c编译成lib库就行了,delphi可以调用的,又何必转呢?
 
多人接受答案了。
 
后退
顶部