📄 gprs.lst
字号:
C51 COMPILER V8.02 GPRS 01/09/2009 16:21:02 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE GPRS
OBJECT MODULE PLACED IN GPRS.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE program\GPRS.C LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\GPRS.lst) OBJECT(GPR
-S.obj)
line level source
1 #include "CM240128.H"
2 #include "C8051F020.h"
3 #include <string.h>
4 #include "数据存储.h"
5
6 //--------------------------------------------------------------------------------------------------------
----------
7
8 void UART0Write(unsigned char *pbuf,unsigned char count)
9 {
10 1 bit c;
11 1 if(count==0)return;
12 1 c=EA;
13 1 EA=0;
14 1 TI0=0;
15 1 while(count--)
16 1 {
17 2 SBUF0 = *pbuf++;
18 2 while(!TI0);
19 2 TI0=0;
20 2 }
21 1 EA=c;
22 1 }
23 //--------------------------------------------------------------------------------------------------------
----------
24
25
26 void UART1Write(unsigned char *pbuf,unsigned char count)
27 {
28 1 bit c;
29 1 if(count==0)return;
30 1 c=EA;
31 1 EA=0;
32 1 //SCON1=SCON1&0xfd;
33 1 UART1ClrTI();
34 1 while(count--)
35 1 {
36 2 SBUF1 = *pbuf++;
37 2 while(!UART1GetTI());
38 2 UART1ClrTI();
39 2 }
40 1 EA=c;
41 1 }
42 //
43 //--------------------------------------------------------------------------------------------------------
----------
44
45 unsigned char UART0Read(unsigned char *pbuf)
46 {
47 1 unsigned int i;
48 1 unsigned char cnt;
49 1 cnt=0;
50 1 RI0=0;
51 1 for(i=0;i<60000;i++)
C51 COMPILER V8.02 GPRS 01/09/2009 16:21:02 PAGE 2
52 1 {
53 2 if(RI0!=0)
54 2 {
55 3 RI0=0;
56 3 i=0;
57 3 cnt++;
58 3 *pbuf++ = SBUF0;
59 3 }
60 2 }
61 1 return cnt;
62 1 }
63 //--------------------------------------------------------------------------------------------------------
----------
64 //字符串寻找
65 //判断字符串srcstr中是否包含substr
66 //返回 0:不包含
67 // 1:包含
68 unsigned char StrFind(unsigned char *srcstr,unsigned char *substr)
69 {
70 1 unsigned char *psrc,*psub,srcln,subln,i,j;
71 1 psrc = srcstr;psub = substr;
72 1 srcln = strlen(psrc);
73 1 subln = strlen(psub);
74 1 for(i=0;i<srcln;i++)
75 1 {
76 2 if(psrc[i]==psub[0])
77 2 {
78 3 for(j=0;j<subln;j++)
79 3 if(psrc[i+j]!=psub[j])break;
80 3 if(j==subln)return 1;
81 3 }
82 2 }
83 1 return 0;
84 1 }
85 //--------------------------------------------------------------------------------------------------------
----------
86 //unsigned char DDDDDDDD;//ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
87 void GPRSInit(void)
88 {
89 1 xdata unsigned char buf[100];
90 1 unsigned char cnt,j,sendcnt;
91 1 unsigned int i;
92 1 // if(DDDDDDDD!=0xaa)return;//ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
93 1 UART0SETUP(57600,8);//设置串口
94 1 UART0DISABLE();//关串口中断
95 1
96 1 SetCurrLoc(0,16);
97 1 DisplayFill(' ',180);//清除显示区
98 1
99 1
100 1 for(i=0;i<60000;i++);
101 1
102 1 for(j=0;j<10;j++)
103 1 {
104 2
105 2 UART0Write("AT\r\n",4);
106 2 cnt = UART0Read(buf);buf[cnt]='\0';
107 2 if(cnt!=0)
108 2 if(StrFind(buf,"OK"))
109 2 break;
110 2 for(i=0;i<60000;i++);
111 2 }
C51 COMPILER V8.02 GPRS 01/09/2009 16:21:02 PAGE 3
112 1 if(j>=10){SetCurrLoc(0,16);DisplayStr("GPRS模块连接:ERR",30);}
113 1 else{SetCurrLoc(0,16);DisplayStr("GPRS模块连接:OK",30);}
114 1
115 1 // for(i=0;i<60000;i++);
116 1 for(sendcnt=0;sendcnt<3;sendcnt++)
117 1 {
118 2 SetCurrLoc(0,32);
119 2 UART0Write("AT+CGDCONT=1,\"IP\",\"CMNET\"\r\n",27);
120 2 cnt = UART0Read(buf);buf[cnt]='\0';
121 2 if(cnt!=0)
122 2 if(StrFind(buf,"OK"))
123 2 {
124 3 DisplayStr("GPRS配置服务商:OK",30);
125 3 break;
126 3 }
127 2 }
128 1 if(sendcnt==3)DisplayStr("GPRS配置服务商:ERR",30);
129 1
130 1 // for(i=0;i<60000;i++);
131 1 for(sendcnt=0;sendcnt<3;sendcnt++)
132 1 {
133 2 SetCurrLoc(0,48);
134 2 UART0Write("AT%CGPCO=1,\"PAP,,\" ,1\r\n",23);
135 2 cnt = UART0Read(buf);buf[cnt]='\0';
136 2 if(cnt!=0)
137 2 if(StrFind(buf,"OK"))
138 2 {
139 3 DisplayStr("GPRS配置用户:OK",30);
140 3 break;
141 3 }
142 2 }if(sendcnt==3)DisplayStr("GPRS配置用户:ERR",30);
143 1
144 1 // for(i=0;i<60000;i++);
145 1 for(sendcnt=0;sendcnt<3;sendcnt++)
146 1 {
147 2 SetCurrLoc(0,64);
148 2 //UART0Write("AT$DESTINFO=\"218.60.36.112\",1,8002\r\n",36);
149 2 UART0Write("AT$DESTINFO=\"",13);
150 2 UART0Write(ServerIp,strlen(ServerIp));
151 2 UART0Write("\",1,8002\r\n",10);
152 2 cnt = UART0Read(buf);buf[cnt]='\0';
153 2 if(cnt!=0)
154 2 if(StrFind(buf,"OK"))
155 2 {
156 3 DisplayStr("GPRS配置IP地址:OK",30);
157 3 break;
158 3 }
159 2 }if(sendcnt==3)DisplayStr("GPRS配置IP地址:ERR",30);
160 1
161 1 // for(i=0;i<60000;i++);
162 1
163 1 SetCurrLoc(0,80);
164 1 UART0Write("ATD*97#;\r\n",10);
165 1 for(i=0;i<20;i++)
166 1 {
167 2 cnt = UART0Read(buf);buf[cnt]='\0';
168 2 if(cnt!=0)
169 2 {
170 3 // DisplayStr(buf,30);
171 3 if(StrFind(buf,"OK"))
172 3 break;
173 3 cnt=0;
C51 COMPILER V8.02 GPRS 01/09/2009 16:21:02 PAGE 4
174 3 }
175 2 }
176 1 UART0ENABLE();//开串口中断
177 1 }
178 //--------------------------------------------------------------------------------------------------------
----------
179 void GPRSEnd(void)
180 {
181 1 /*
182 1 xdata unsigned char buf[100];
183 1 unsigned char j,cnt,n;
184 1 unsigned int i;
185 1 */
186 1 UART0SETUP(57600,8);//设置串口
187 1 UART0DISABLE();//关串口中断
188 1 ClrDisplay();
189 1 /*
190 1 SetCurrLoc(0,16);DisplayStr("GPRS模块断开程序",30);
191 1 for(j=0;j<10;j++)
192 1 {
193 1 UART0Write("+++",3);
194 1 for(n=0;n<10;n++)for(i=0;i<60000;i++);
195 1 UART0Write("AT\r\n",4);
196 1 cnt = UART0Read(buf);buf[cnt]='\0';
197 1 if(cnt!=0)
198 1 if(StrFind(buf,"OK"))
199 1 break;
200 1 for(i=0;i<60000;i++);
201 1 }
202 1 if(j>=10){SetCurrLoc(0,16);DisplayStr("GPRS模块断开:ERR",30);}
203 1 else{SetCurrLoc(0,16);DisplayStr("GPRS模块断开:OK",30);}
204 1 */
205 1 }
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1173 ----
CONSTANT SIZE = 244 ----
XDATA SIZE = ---- 133
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
C51 COMPILER V8.02 GPRS 01/09/2009 16:21:02 PAGE 5
BIT SIZE = ---- 2
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -