void Ascii2DecCmd(void)
{
int i=0;
memset(TcpRx,0,RX_MAX_LEN);
uint8_t temp[256] = {0};
for(i=0;i<USART4_RX_LEN;i++)
{
if(USART4_RX_BUF[i] >= '0' && USART4_RX_BUF[i] <= '9')
{
temp[i] = USART4_RX_BUF[i] - '0';
}
else if(USART4_RX_BUF[i] >= 'a' && USART4_RX_BUF[i] <= 'f')
{
temp[i] = USART4_RX_BUF[i] - 'a' + 10;
}
else if(USART4_RX_BUF[i] >= 'A' && USART4_RX_BUF[i] <= 'F')
{
temp[i] = USART4_RX_BUF[i] - 'A' + 10;
printf("fff = %d temp[i] = %d,'A' = %d\n",USART4_RX_BUF[i],temp[i],'A');
}
}
for(i=0;i<USART4_RX_LEN ;i+=2)
{
TcpRx[i / 2] = temp[i] << 4 | temp[i+1];
printf("temp[i] = %d,temp[i+1] = %d, TcpRx[i / 2] = %d\n",temp[i],temp[i+1],TcpRx[i/2]);
}
for(i=0;i<USART4_RX_LEN / 2 ;i++)
{
printf("%d\n",TcpRx[i]);
}
}
void Printf_OutHex(uint8_t *arry, uint16_t length)
{
uint16_t i;
printf("\r\n");
for(i=0; i<length; i++)
{
printf("%02X ",arry[i]);
}
printf("\r\n");
}
static unsigned char ascii2dex(unsigned char temp)
{
if(temp >= '0' && temp <= '9')
return temp - '0';
else if(temp >= 'a' && temp <= 'f')
return temp - 'a'+10;
else if(temp >= 'A' && temp <= 'F')
return temp - 'A'+10;
else
return 0;
}