十六进制数转换为十进制
/*
由于发过来的数据为16进制,故需要把16进制的数据变为10进制,然后由Mat进行保存
*/
static int hex_table[] = { 0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,1,2,3,4,5,6,
7,8,9,0,0,0,0,0,0,
0,10,11,12,13,14,15,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,10,
11,12,13,14,15 };
unsigned char hex_to_decimal(char* hex_str)
{
char ch;
unsigned char iret = 0;
while (ch = *hex_str++)
{
iret = (iret << 4) | hex_table[ch];
}
return iret;
}