不知道具体什么作用
void hex_2_asc(uchar *_src,unsigned int cnt,uchar *_dest)
{
while (cnt-->0)
{
if (((_src[cnt] & 0xF0)>>4)<=9) _dest[cnt*2] = 0x30 + ((_src[cnt] & 0xF0)>>4); else _dest[cnt*2] = 0x37 + ((_src[cnt] & 0xF0)>>4);
if ((_src[cnt] & 0x0F)<=9) _dest[cnt*2+1] = 0x30 + (_src[cnt] & 0x0F); else _dest[cnt*2+1] = 0x37 + (_src[cnt] & 0x0F);
}
}
void hex_2_dec(unsigned long int _hex,char *_dec)
{
unsigned char i,x;
unsigned long int J;
memset(_dec,0x00,16);
J=10000000;
for (i=0;i<8;i++)
{
x=_hex/J;
_hex=_hex-J*x;
J=J/10;
if (i % 2)
{_dec[i/2]=_dec[i/2]*16+x;}
else
{
_dec[i/2]=_dec[i/2]+x;
}
}
}
void dec_2_hex(uchar *strDec,int n,uchar *strHex)
{
int i;
unsigned long int *a;
(uchar*)a=&strHex[0];
*a=10;
for (i=0;i<n;i++)
{
(*a)=(*a)*10+strDec[i]-0x30;
}
}
void CRC16(unsigned char* src, unsigned char* crc16, int len)
{
unsigned long int crc=0;
unsigned char i;
unsigned char *ptr=src;
while (len--)
{
for (i=0x80; i!=0; i=i>>1)
{
if ((crc & 0x8000) !=0)
{
crc = crc <<1;
crc = crc^0x1021;
}
else
{
crc = crc << 1;
}
if ((*ptr & i) != 0)
{
crc = crc^0x1021;
}
}
ptr++;
}
memcpy(crc16,&crc,4);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我看也是,有点复杂,在研究研究,谢谢
一周热门 更多>