Home » Source Code » » yyshell.c - uCOS 51 Shell V2....
Click here to see more ▼
Click here to hide ▲

yyshell.c - uCOS 51 Shell V2....


Code description:uCOS 51 Shell V2....
			//**********************************************************************************
//杨屹    2002/08/21    第一版
//我的主程序(SNMP网管板)
//联系方法:gdtyy@ri.gdt.com.cn(2003/07/31以前有效)
//**********************************************************************************

#include   <includes.h>

static unsigned char ComTable[MaxComNum][MaxLenCom+1]={
"lt","kill","ping","udp","host","mask","gateway","exit","ipcfg","clr","help"
};			
			
int State=StatInputCom;
unsigned char ch;
int ShellEnd=0;		/*Shell end flag*/
unsigned char ComBuf[MaxLenComBuf+1];	/*store '\0'*/
int i=-1;			/*ComBuf pointer*/
int tem;			/*Temp variable*/
int ComMatchFlag=0;		/*Command match flag*/

WORDTABLE WordTable;
	
int Matched=0;	/*Match flag*/

OS_STK yyshellStk[MaxStkSize];//注意:我在ASM文件中设置?STACK空间为40H即64,不要超出范围。用户栈多一个字节存长度
	
xdata union ip_address_type my_ip_address;      //本机的ip地址
xdata union ip_address_type temp_ip_address;    //临时变量
xdata union ip_address_type mask_ip_address;    //子网掩码
xdata union ip_address_type gateway_ip_address;	//网关的ip地址
xdata union ip_address_type ping_ip_address;	//用于ping命令

void main(void)
{

    OSInit();
    
    InitTimer0();
    InitSerial();
    InitSerialBuffer();
    
    //初始化网络参数
    IPadrToHEX("172.18.92.87",&my_ip_address.bytes[0]);
    IPadrToHEX("255.255.255.0",&mask_ip_address.bytes[0]);
    IPadrToHEX("172.18.91.5",&gateway_ip_address.bytes[0]);    
    
    OSTaskCreate(yyshell, (void *)0, &yyshellStk[0],8);    
    
    OSStart();

}

void yyshell(void *yydata) reentrant
{

	yydata=yydata;
	clrscr();
	PrintStr("\t\t***********************************************\n");
	PrintStr("\t\t*         Welcom to use this program          *\n");
	PrintStr("\t\t*                   Author:YangYi 20020715    *\n");
	PrintStr("\t\t***********************************************\n\n\n");
		
	/*Login & Password*/

	PrintStr("% ");
	while(!ShellEnd){


		switch(State){

			case StatInputCom:{

				if(yygetch(&ch)){

					if(ch==13)	/*Enter return key*/
					{

						PrintStr("\n");
						ComBuf[i+1]='\0';					
						if(i+1==0) PrintStr("% ");
						else					
						State=StatExeCom;
					
}
					else{

						i=i+1;
						if((i>=MaxLenComBuf)&&(ch!=8)){

							PrintChar(7);
							i=MaxLenComBuf-1;
						
}
						else{

							if(ch==8){

								i=i-2;
								if(i<-1) {
i=-1;PrintChar(7);
}
								else{

									PrintChar(8);
									PrintChar(' ');
									PrintChar(8);
								
}
							
}
							else{

								PrintChar(ch);
								ComBuf[i]=ch;
							
}
						
}
					
}
					break;
				
}
				else{

					//OSTimeDly(10);
					break;
				
}
			
}
			case StatExeCom:{

				if(GetWord(ComBuf,&WordTable)==1&&WordTable.Num!=0){

					yystrlwr(WordTable.wt[0].Str);
					for(tem=0;tem<MaxComNum&&!ComMatchFlag;tem++)
						if(yystrcmp(WordTable.wt[0].Str,ComTable[tem])==0) ComMatchFlag=1;
					if(ComMatchFlag){

						tem--;
						switch(tem){

							case 0:{
DisplayTask(&WordTable);break;
}
							case 1:{
Kill(&WordTable);break;
}
							case 2:{
PingCommand(&WordTable);break;
}
							case 3:{
UDPCommand(&WordTable);break;
}
							case 4:{
CfgHost(&WordTable);break;
}
                           				case 5:{
CfgMask(&WordTable);break;
}
							case 6:{
CfgGateway(&WordTable);break;
}							
                            				case 7:{

								//ShellEnd=1;
								PrintStr("\n\tThis Command is limited!\n\n");
								break;
							
}
							case 8:{
PrintConfig(&WordTable);break;
}
							case 9:{
clrscr();break;
}
							case 10:{
DisplayHelpMenu(&WordTable);break;
}
						
}							
					
}
					else
						PrintStr("    Bad command!\n\n");
				
}
				else{

					if(WordTable.Num) PrintStr("    Bad command!\n\n");
				
}

				ComMatchFlag=0;
				State=StatInputCom;
				if(ShellEnd) {
PrintStr("\n\n");
}
				else PrintStr("% ");
				i=-1;
				break;
			
}
			default:{

				//ShellEnd=1;
				PrintStr("System fatal error!\n");
				PrintChar(7);PrintChar(7);PrintChar(7);
			
}
		
}
	
}

}
			
Expand> <Close
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
NameSizeDate
 02.00 B
 readme.txt107.00 B02-23-04 11:10
 02.00 B
 INCLUDES.H1.02 kB10-05-02 10:07
 mystring.c2.45 kB10-05-02 10:06
 mystring.h842.00 B08-21-02 08:36
 OS_CFG.H3.64 kB10-21-02 08:20
 OS_CORE.C38.63 kB09-30-02 11:16
 OS_CPU.H3.09 kB10-21-02 08:20
 OS_CPU_A.ASM8.12 kB10-08-02 16:38
 OS_CPU_C.C8.44 kB05-16-03 17:29
 OS_MBOX.C11.88 kB09-29-02 16:53
 OS_MEM.C10.67 kB09-29-02 16:54
 OS_Q.C20.25 kB09-29-02 16:55
 OS_SEM.C11.08 kB09-29-02 16:55
 OS_TASK.C34.86 kB09-29-02 16:56
 OS_TIME.C9.10 kB09-28-02 17:35
 serial.c7.56 kB02-20-04 10:16
 serial.h2.90 kB09-29-02 17:42
 shell.Opt2.24 kB02-20-04 10:31
 shell.plg161.00 B02-20-04 10:31
 shell.Uv22.24 kB02-20-04 10:31
 Startup.asm5.00 kB11-26-02 11:32
 UCOS_II.C1.03 kB02-20-04 10:29
 UCOS_II.H22.94 kB09-30-02 08:31
 word.c1.55 kB10-04-02 23:57
 word.h804.00 B10-05-02 00:01
 yyshell.c4.02 kB10-14-02 14:48
 yyshell.h85.00 B10-05-02 00:32
 yyshellsub.c7.58 kB10-05-02 14:00
 yyshellsub.h1.10 kB10-05-02 09:48
 ο7.05 kB02-20-04 15:42
...
Sponsored links
×

Login CodeForge

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com
×

Sorry, you don't have enough CF coins! ^_^|||

Fast channel (Get CF coins immediately):

10 CF coins (points) for $20.00 USD
22 CF coins (points) for$40.00USD
55 CF coins (points) for$100.00USD
120 CF coins (points) for$200.00USD
Free channel :

Submit your source codes
You could get 1-10 CF coins
More……
×

切换到中文版?

×

Where are you going?

×

Tips

This user hasn't enable blog!
×

Tips

Favorite by Ctrl+D