C语言到JAVA语言的程序翻译

Arthur 发布于 2014/06/22 14:17
阅读 1K+
收藏 0
/*
CRC16_h_
*/
#ifndef_CRC16_H
#define_CRC16_H
unsignedshortCRC16(unsignedchar*puchMsg,unsignedshortusDataLen);
#endif
#include"CRC16.h"
/*CRC
#include"sys_init.h"
lowbyte
*/
staticconstunsignedcharauchCRCHi[]={
0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,
0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,
0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,
0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,
};

/*CRC
highbyte
*/
staticconstunsignedcharauchCRCLo[]={
0x00,0xC0,0xC1,0x01,0xC3,0x03,0x02,0xC2,0xC6,0x06,
0x07,0xC7,0x05,0xC5,0xC4,0x04,0xCC,0x0C,0x0D,0xCD,
0x0F,0xCF,0xCE,0x0E,0x0A,0xCA,0xCB,0x0B,0xC9,0x09,
0x08,0xC8,0xD8,0x18,0x19,0xD9,0x1B,0xDB,0xDA,0x1A,
0x1E,0xDE,0xDF,0x1F,0xDD,0x1D,0x1C,0xDC,0x14,0xD4,
0xD5,0x15,0xD7,0x17,0x16,0xD6,0xD2,0x12,0x13,0xD3,
0x11,0xD1,0xD0,0x10,0xF0,0x30,0x31,0xF1,0x33,0xF3,
0xF2,0x32,0x36,0xF6,0xF7,0x37,0xF5,0x35,0x34,0xF4,
0x3C,0xFC,0xFD,0x3D,0xFF,0x3F,0x3E,0xFE,0xFA,0x3A,
};
unsignedshortCRC16(unsignedchar*puchMsg,unsignedshortusDataLen)
{
unsignedcharuchCRCHi=0xFF;
unsignedcharuchCRCLo=0xFF;
unsigneduIndex=0 ;
while(usDataLen--)
{
uIndex=uchCRCHi^*puchMsg++;
uchCRCHi=uchCRCLo^auchCRCHi[uIndex];//
uchCRCLo=auchCRCLo[uIndex];
}
return(unsignedshort)((unsignedshort)uchCRCHi<<8| uchCRCLo);
}

谁能帮忙翻译一下这段代码 从C到java

加载中
0
中山野鬼
中山野鬼
哈哈。写c的不会java,写java的不会c,这不是难为大家嘛。。。
0
c
cloudcheng
曾经做C的,现在做PHP学java,等我学完了帮你翻译
memristor
memristor
做c语言的为何改行?我以前做php的,现在想搞c与cpp
0
pseudo
pseudo
你翻译出来也没用,这段程序需要"CRC16.h"和"sys_init.h"这两个头文件,就算用java写出来也运行不了。
0
CloudArchitect
CloudArchitect
我到时很好奇为啥要翻译
0
little_kid
little_kid
查表法快速计算CRC16.。。C和java没啥区别啊
返回顶部
顶部