⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_link.lst

📁 外部接传感器完成数据采集
💻 LST
📖 第 1 页 / 共 5 页
字号:
  86      =1  #define RR                5     
  87      =1  #define RNR               6   
  88      =1  #define REJ               7     
  89      =1  #define FRMR              8    
  90      =1  #define CNET              9     
  91      =1  #define DISC              10
  92      =1  
  93      =1  
  94      =1  #define OK                0
  95      =1  #define SUCCESS           1     
  96      =1  #define	XMIT_INT_ON	  (TI=1)             
  97      =1  #define PPPINITFCS16      0xffff
  98      =1  #define MAX_CONTENT       10028
  99      =1  #define	SECS_PER_MINUTE   60
 100      =1  #define	SECS_PER_HOUR	  3600
 101      =1  #define	SECS_PER_DAY	  86400
 102      =1  
 103      =1  
 104      =1  
 105      =1       
 106      =1  
  12          #include <lcd_ext.h>
   1      =1  extern unsigned char xdata xmit_numC;
   2      =1  extern unsigned char timer_cnt_b,timer_cnt_h;
   3      =1  extern unsigned int  xdata sadrS,dadrS; //源地址 目的地址
   4      =1  
   5      =1  extern struct{	
   6      =1  	unsigned char xmit_cntC;
   7      =1  	unsigned char rec_cntC;
   8      =1  	unsigned char rec_numC;
   9      =1  	unsigned char frm_headC;
  10      =1  	unsigned char rec_overC;
  11      =1  	unsigned char * xmit_bufCP;
  12      =1  	unsigned char * rec_bufCP;
  13      =1  	unsigned char rec_bufCA[256];
  14      =1  	unsigned char xmit_bufCA[256];	
  15      =1  }xdata comS; //串口数据
  16      =1  
  17      =1  extern struct{
  18      =1  	unsigned char cmd;
  19      =1  	unsigned char cmd_mode; 
  20      =1  	unsigned char cmd_flg;
  21      =1  	unsigned int  lenC;
  22      =1  	unsigned char val_cnt; 
  23      =1  	unsigned char sub_flg[5];
  24      =1  	unsigned char sub_cmd[5];
  25      =1  	unsigned char para_num[5];       
  26      =1  }xdata frmS; //实时数据
  27      =1  
  28      =1  /*extern struct{
  29      =1  	unsigned long int lenC;
  30      =1  	unsigned long int cntC;       
C51 COMPILER V5.10,  SN-  LCD_LINK                                                         01/07/08  08:57:39  PAGE 19  

  31      =1  	unsigned long int numC;  
  32      =1  	unsigned char *bufCP;
  33      =1  	unsigned char bufCA[MAX_CONTENT]; 
  34      =1  }xdata note; //10K自记数据*/
  35      =1  
  36      =1  /*extern struct{
  37      =1  	unsigned char cmd;
  38      =1  	unsigned char cmd_flg;
  39      =1  	unsigned char data_type;
  40      =1  	unsigned int  cntC;
  41      =1  	unsigned long int time_seC;
  42      =1  	unsigned long int begin_timeC;
  43      =1  	unsigned long int end_timeC;
  44      =1  	unsigned char *valCP;
  45      =1  	unsigned char valCA[4];
  46      =1  	unsigned char begin_timeCA[12];
  47      =1  	unsigned char end_timeCA[12];
  48      =1  }xdata colg; //综合数据*/ 
  49      =1  
  50      =1  extern struct{
  51      =1  	char numC;             
  52      =1  	unsigned char clmnC;
  53      =1  	unsigned char pageC;   
  54      =1  	unsigned long int totl_seC;
  55      =1  	unsigned char *valCP;
  56      =1  	unsigned char valCA[13];
  57      =1  	unsigned long int currCA[7];
  58      =1  }xdata sys_timeS; //系统时间
  59      =1  
  60      =1  extern struct{	        
  61      =1  	unsigned char clmnC;
  62      =1  	unsigned char cntC;
  63      =1  	unsigned char numC;
  64      =1  	unsigned int  adrC;
  65      =1  	unsigned char *adrCP; 
  66      =1  	unsigned char adrCA[5];
  67      =1  }xdata stat; //站号
  68      =1  
  69      =1  extern struct{
  70      =1  	unsigned char  set_cnt; 
  71      =1  	char  numC;
  72      =1  	unsigned char  clmnC;
  73      =1  	unsigned char  pageC;
  74      =1  	unsigned char  distinction; 
  75      =1  	unsigned char  isonerain; 
  76      =1  	unsigned int   rainCA_cnt;
  77      =1  	unsigned char  set_buf[14];
  78      =1  	unsigned int   parameter[3][4]; 
  79      =1  	float          max_rain[3];
  80      =1  	float          rainCA[289]; 
  81      =1  }xdata alarm; //报警                
  13          //判断是否是匹配站号 
  14          long int is_matching_stat(unsigned char *p)
  15          {          
  16   1      	unsigned int xdata vC;
  17   1      
  18   1      	if(dadrS==0) return(SUCCESS);
  19   1      	else{
  20   2      		vC=(unsigned int)(*(p+3)<<8)+(unsigned int)(*(p+4));
  21   2      		if(vC==dadrS) return(SUCCESS);
  22   2      		else return(OK);             
  23   2      	}       
C51 COMPILER V5.10,  SN-  LCD_LINK                                                         01/07/08  08:57:39  PAGE 20  

  24   1      }
  25          //判断是否是命令帧
  26          long int is_cmd_frm(unsigned char *p)
  27          {
  28   1      	unsigned char xdata vC;
  29   1        
  30   1      	vC = *(p + 5);
  31   1      	if(vC & 0x80){
  32   2      		return(SUCCESS);
  33   2      	}
  34   1      	return(OK);
  35   1      }
  36          //判断PF是否置位(是否需要回UA帧)  
  37          long int pf_is_set(unsigned char *p)
  38          {
  39   1      	unsigned int xdata v;
  40   1      	unsigned char xdata c;
  41   1        
  42   1      	v=(unsigned int)get_ctl_offset(p);
  43   1      	c = *(p + v + 4);
  44   1      	if(c & 0x80){
  45   2      		return(SUCCESS);
  46   2      	}
  47   1      	return(OK);
  48   1      }
  49          
  50          //链接处理
  51          void link_proc(void)
  52          {
  53   1      	long int xdata vc;
  54   1      	
  55   1      	if(rec_frmC()){
  56   2      		comS.rec_bufCP=comS.rec_bufCA;
  57   2      		//if(chk_event_flagI(DIS_COLG_VAL)){
  58   2      		//	set_event_flag(KEY_INTERMIT);
  59   2      		//}              
  60   2      		vc=is_matching_stat(comS.rec_bufCP);
  61   2      		if(vc==SUCCESS){
  62   3      			vc=is_cmd_frm(comS.rec_bufCP);
  63   3      			if(vc==SUCCESS){                        
  64   4      				vc=get_frm_type(comS.rec_bufCP);
  65   4      				get_stat_adr();
  66   4      				switch(vc){
  67   5      
  68   5      					/*case CNET:
  69   5      					if(chk_event_flagI(IS_IFRM_LINK)){
  70   5      						create_ua_frm();
  71   5      						set_event_flag(NEED_REC);
  72   5      					}
  73   5      					break;
  74   5      
  75   5      					case I:
  76   5      					if(chk_event_flagI(IS_IFRM_LINK)){
  77   5      						create_rr_frm();
  78   5      						set_event_flag(NEED_REC);
  79   5      						copy_com_frm();
  80   5      					}
  81   5      					break;
  82   5      
  83   5      					case DISC:
  84   5      					if(chk_event_flagI(IS_IFRM_LINK)){
  85   5      						create_dm_frm();
C51 COMPILER V5.10,  SN-  LCD_LINK                                                         01/07/08  08:57:39  PAGE 21  

  86   5      						clr_event_flag(IS_IFRM_LINK);
  87   5      						set_event_flag(DIS_COLG_VAL);
  88   5      						dis_colg_val();
  89   5      					}
  90   5      					break;*/
  91   5      
  92   5      					case UI:
  93   5      					if(pf_is_set(comS.rec_bufCP)){
  94   6      						create_ua_frm();
  95   6      					}
  96   5      					frm_proc();
  97   5      					break;
  98   5      
  99   5      					default:
 100   5      					break;
 101   5      				}
 102   4      			}
 103   3      		}
 104   2      	}
 105   1      	is_again_xmit();
 106   1      	proc_com_interfere();
 107   1      }
 108          
 109          //获得帧类型
 110          long int get_frm_type(unsigned char *p)
 111          {
 112   1      	unsigned char xdata c;
 113   1      	unsigned long int xdata v;
 114   1      
 115   1      	v = get_ctl_offset(p);
 116   1      	c = comS.rec_bufCA[v];
 117   1      	if(!(c & 0x01)){
 118   2      		return(I); 
 119   2      	}
 120   1      	c &= 0x0f;
 121   1      	if(c == 0x01){ 
 122   2      		return(RR);
 123   2      	}
 124   1      	if(c == 0x05){
 125   2      		return(RNR);
 126   2      	}
 127   1      	if(c == 0x09){
 128   2      		return(REJ);
 129   2      	}
 130   1      	c = comS.rec_bufCA[v];
 131   1      	c &= 0xef;
 132   1      	if(c == 0x03){
 133   2      		return(UI);
 134   2      	}
 135   1      	if(c == 0x2f){
 136   2      		return(CNET);
 137   2      	}
 138   1      	if(c == 0x43){
 139   2      		return(DISC);
 140   2      	}
 141   1      	if(c == 0x0f){
 142   2      		return(DM);
 143   2      	}
 144   1      	if(c == 0x63){
 145   2      		return(UA);
 146   2      	}
 147   1      	if(c == 0x87){
C51 COMPILER V5.10,  SN-  LCD_LINK                                                         01/07/08  08:57:39  PAGE 22  

 148   2      		return(FRMR);
 149   2      	}
 150   1      	return(OK);
 151   1      }
 152          
 153          //获得帧长度
 154          unsigned int get_frm_len(void)
 155          {
 156   1      	unsigned char xdata s;
 157   1      	unsigned int xdata lenC;
 158   1      
 159   1      	comS.rec_bufCP=comS.rec_bufCA;
 160   1      	s=get_ctl_offset(comS.rec_bufCP);
 161   1      	lenC=(unsigned int)(*(comS.rec_bufCP+s+1)<<8)+(unsigned int)(*(comS.rec_bufCP+s+2));
 162   1      	return(lenC);
 163   1      }
 164          
 165          /*//复制自记数据到内存
 166          void copy_com_frm(void)
 167          {
 168          	unsigned char xdata s;
 169          	unsigned int xdata frm_lenC;
 170          
 171          	note.bufCP=&note.bufCA[note.lenC];
 172          	comS.rec_bufCP=comS.rec_bufCA;              
 173          	frm_lenC=get_frm_len();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -