/***********************************************************************
Name:void rs232_visit(unsignde int i)
Function:void
Input:none
Output:none
************************************************************************/
void rs232_visit()
{
unsigned char cmdbuf;
unsigned char rs232_cmd[10];
unsigned char *ptr1, *ptr2;
unsigned char temp = 0;
unsigned char str[8];
unsigned int number = 0;
//len = 1;
ptr2 = rs232_cmd;
while (temp != '\r')
{
//if(getc(&cmdbuf,1,timeout,0) == 0x01)//get a character from
getc (&cmdbuf, 1, 0);
//return;//timeout, return
//ptr1 = cmdbuf;
*ptr2 = cmdbuf;
temp = *ptr2;
putc (*ptr2, 0);
ptr2++;
}
*ptr2 = 0;
if ( (!number_flag) && (strcmp (rs232_cmd, "\r") == 0) )
{
newline();
puts (">", 0);//display prompt
}
else if ( (!number_flag) && (strcmp (rs232_cmd, "?\r") == 0) )
{
newline();
puts ("show menu...", 0);
display_cmd();
}
else if ( (!number_flag) && (strcmp (rs232_cmd, "s\r") == 0) )
{
newline();
puts ("save eeprom...", 0);
store_flag = 1;
//display_cmd();
}
else if ( (!number_flag) && (strcmp (rs232_cmd, "start\r") == 0) )
{
newline();
puts ("start test,ready go...", 0);//
}
else if ( (!number_flag) && (strcmp (rs232_cmd, "d\r") == 0) ) //show voltage of 24V and 5V5
{
//vdd_24v = 30000;
num2asc (vdd_24v, str, 3);
newline();
puts ("The VDD_24V = ", 0);
puts (str, 0);
putc ('V', 0);
num2asc (vdd_5v5, str, 3);
newline();
puts ("The VCC_5V5 = ", 0);
puts (str, 0);
putc ('V', 0);
newline();
puts (">", 0);//display prompt
}
else if ( (!number_flag) && (strcmp (rs232_cmd, "g\r") == 0) ) //get voltaga
{
//ptr2 = str;
newline();
number_flag = 1;
puts ("please input number(0-65535):", 0);
//while(temp != '\r')
//{
// if(getc(&cmdbuf,1,timeout,0) == 0x01)//get a character from
// return;//timeout, return
//ptr1 = cmdbuf;
//*ptr2 = cmdbuf;
//temp = *ptr2;
//putc(*ptr2,0);
//ptr2++;
//}
//asc2num(str,&number);
//num2asc(number,str,0);
//puts(str,0);
//newline();
//puts(">",0);//display prompt
}
else if (number_flag) // && (strcmp(rs232_cmd,"0\r") >= 0) && (strcmp(rs232_cmd,"65535\r") <= 0))//get number
{
number_flag = 0;
//if(asc2num(rs232_cmd,&number) == 0x02)
if (asc2num (rs232_cmd, &number) == 0x02)
{
num2asc (number, str, 0);
//number = 0;
newline();
puts ("You have inputed:", 0);
puts (str, 0);
newline();
puts (">", 0);//display prompt
}
}
else
{
newline();
//if(number_flag)
//{
//number_flag = 0;
//puts("Your input is not number.",0);
//}
//else
//{
puts ("The command is undefined!", 0);
//}
newline();
puts (">", 0);//display prompt
}
} |