Home » Source Code » » yyshell.c

yyshell.c ( File view )

From:
Description:uCOS 51 Shell V2....
  • By 2010-08-31
  • View(s):7
  • Download(s):0
  • Point(s): 1
			//**********************************************************************************
//杨屹    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

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
源码文件 002.00 B
code file readme.txtreadme.txt107.00 B02-23-04 11:10
源码文件 002.00 B
code file INCLUDES.HINCLUDES.H1.02 kB10-05-02 10:07
code file mystring.cmystring.c2.45 kB10-05-02 10:06
code file mystring.hmystring.h842.00 B08-21-02 08:36
code file OS_CFG.HOS_CFG.H3.64 kB10-21-02 08:20
code file OS_CORE.COS_CORE.C38.63 kB09-30-02 11:16
code file OS_CPU.HOS_CPU.H3.09 kB10-21-02 08:20
code file OS_CPU_A.ASMOS_CPU_A.ASM8.12 kB10-08-02 16:38
code file OS_CPU_C.COS_CPU_C.C8.44 kB05-16-03 17:29
code file OS_MBOX.COS_MBOX.C11.88 kB09-29-02 16:53
code file OS_MEM.COS_MEM.C10.67 kB09-29-02 16:54
code file OS_Q.COS_Q.C20.25 kB09-29-02 16:55
code file OS_SEM.COS_SEM.C11.08 kB09-29-02 16:55
code file OS_TASK.COS_TASK.C34.86 kB09-29-02 16:56
code file OS_TIME.COS_TIME.C9.10 kB09-28-02 17:35
code file serial.cserial.c7.56 kB02-20-04 10:16
code file serial.hserial.h2.90 kB09-29-02 17:42
源码文件 shell.Optshell.Opt2.24 kB02-20-04 10:31
源码文件 shell.plgshell.plg161.00 B02-20-04 10:31
源码文件 shell.Uv2shell.Uv22.24 kB02-20-04 10:31
code file Startup.asmStartup.asm5.00 kB11-26-02 11:32
code file UCOS_II.CUCOS_II.C1.03 kB02-20-04 10:29
code file UCOS_II.HUCOS_II.H22.94 kB09-30-02 08:31
code file word.cword.c1.55 kB10-04-02 23:57
code file word.hword.h804.00 B10-05-02 00:01
code file yyshell.cyyshell.c4.02 kB10-14-02 14:48
code file yyshell.hyyshell.h85.00 B10-05-02 00:32
code file yyshellsub.cyyshellsub.c7.58 kB10-05-02 14:00
code file yyshellsub.hyyshellsub.h1.10 kB10-05-02 09:48
源码文件 οο7.05 kB02-20-04 15:42
...
Sponsored links
×

yyshell.c (59.98 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

×

LOGIN

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

切换到中文版?

CodeForge Chinese Version
CodeForge English Version
×

Where are you going?

×

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK
×

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D