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

📄 5112udp.lst

📁 一个嵌入式系统通过GPRS进行数据传输的程序,协议芯片为5112,程序中描述了通过单片机上网及通过UDP数据传输的过程
💻 LST
📖 第 1 页 / 共 5 页
字号:
 263   2              }
 264   1              killtimer(9);
 265   1              sm=1;
 266   1              send_ctr_com0_buf[0]='A';//send power off command to wavecom
 267   1              send_ctr_com0_buf[1]='T';
 268   1              send_ctr_com0_buf[2]='+';
 269   1              send_ctr_com0_buf[3]='C';
 270   1              send_ctr_com0_buf[4]='P';
 271   1              send_ctr_com0_buf[5]='O';
 272   1              send_ctr_com0_buf[6]='F';
 273   1              send_ctr_com0_buf[7]=0x0d;
 274   1              send_data0=0;
 275   1              send_ctr_com0_len=8;
 276   1              send_com0_cnt=0;
 277   1              send_com0_finish=0;
 278   1              rcv_cnt0=0;
 279   1              send_buf0[2]=0;
 280   1              send_buf0[3]=0;
 281   1              TI=1;
 282   1              while ( ! send_com0_finish )
 283   1              {
 284   2              ;
 285   2              }
 286   1              send_com0_finish=0;
 287   1              i=0;
 288   1              while (1)
 289   1              {
 290   2                      if ( ( send_buf0[2] == 'O' ) & ( send_buf0[3] == 'K' ) ) break;
 291   2                      else
 292   2                      {
 293   3                              wait(100);
 294   3                              i++;
 295   3                              if ( i > 150 ) break;
 296   3                      }
 297   2              }
 298   1              for ( i = 0 ; i < 10 ; i++ ) wait(100);
 299   1              sm=0;
 300   1              rcv_cnt0=0;
 301   1              rcv_7d=0;
 302   1              rcv_data0=0;
 303   1              rcv_command=0;
C51 COMPILER V7.20   5112UDP                                                               08/18/2004 10:31:57 PAGE 6   

 304   1              com0tocom1=0;
 305   1              rcv_data_len=0;
 306   1              chk_add=0;
 307   1              send_to_com1_addr=0;
 308   1              request_send_ack_to_server=0;
 309   1              rcv_chk_cnt=0;
 310   1              rcv_to_send_com1_addr=0;
 311   1              receive_5112=0;
 312   1              DSP_SEND=1;
 313   1              DSP_RCV=1;
 314   1      }
 315          ///////////////////////////////
 316          //
 317          //NAME: sm_prog
 318          //DESCRIPTION: short message program for set socket
 319          //CALL:
 320          //INPUT:
 321          //OUTPUT:
 322          //
 323          ///////////////////////////////
 324          void sm_prog(void)
 325          {
 326   1              unsigned int addr, itemp;
 327   1              unsigned char i,chtemp,ch;
 328   1              unsigned char *p;
 329   1              bit set,reset;
 330   1              reset=0;
 331   1              set=0;
 332   1              sm=1;
 333   1              send_ctr_com0_buf[0]=0x7e;
 334   1              send_ctr_com0_buf[1]=0x39;
 335   1              send_ctr_com0_buf[2]=0x00;
 336   1              send_ctr_com0_buf[3]=0x03;
 337   1              send_ctr_com0_buf[4]=0x7e;
 338   1              send_data0=0;
 339   1              send_ctr_com0_len=5;
 340   1              send_com0_cnt=0;
 341   1              send_com0_finish=0;
 342   1              TI=1;
 343   1              ack=0;
 344   1              settimer(9);
 345   1              while ( !ack )
 346   1              {
 347   2              ;
 348   2              }
 349   1              killtimer(9);
 350   1              DSP_SEND=0;
 351   1              DSP_RCV=0;
 352   1              while( smsindex )
 353   1              {
 354   2                      send_ctr_com0_buf[0]='A';//read short message
 355   2                      send_ctr_com0_buf[1]='T';
 356   2                      send_ctr_com0_buf[2]='+';
 357   2                      send_ctr_com0_buf[3]='C';
 358   2                      send_ctr_com0_buf[4]='M';
 359   2                      send_ctr_com0_buf[5]='G';
 360   2                      send_ctr_com0_buf[6]='R';
 361   2                      send_ctr_com0_buf[7]='=';
 362   2                      if ( smsindex > 9 )
 363   2                      {
 364   3                              ch=smsindex/10;
 365   3                              ch=ch+0x30;
C51 COMPILER V7.20   5112UDP                                                               08/18/2004 10:31:57 PAGE 7   

 366   3                              send_ctr_com0_buf[8]=ch;
 367   3                              ch=smsindex-(smsindex/10)*10+0x30;
 368   3                              send_ctr_com0_buf[9]=ch;
 369   3                              chtemp=10;
 370   3                      }
 371   2                      else
 372   2                      {
 373   3                              send_ctr_com0_buf[8]=smsindex+0x30;
 374   3                              chtemp=9;
 375   3                      }
 376   2                      send_ctr_com0_buf[chtemp]=0x0d;
 377   2                      chtemp++;
 378   2                      send_data0=0;
 379   2                      send_ctr_com0_len=chtemp;
 380   2                      send_com0_cnt=0;
 381   2                      send_com0_finish=0;
 382   2                      rcv_cnt0=0;
 383   2                      TI=1;
 384   2                      while ( ! send_com0_finish )
 385   2                      {
 386   3                      ;
 387   3                      }
 388   2                      wait(150);
 389   2                      wait(150);
 390   2                      wait(150);
 391   2      
 392   2                      for ( addr = 0 ; addr < (rcv_cnt0-6) ; addr++ )
 393   2                      {
 394   3                              if (( send_buf0[addr] == 'F') & ( send_buf0[addr+1] == 'F') & ( send_buf0[addr+2] == 'A') & ( send_buf0
             -[addr+3] == 'A') & ( send_buf0[addr+4] == '5') & ( send_buf0[addr+5] == '5') )
 395   3                              {
 396   4                                      itemp=addr+18;
 397   4                                      if (( send_buf0[itemp] == '5') & ( send_buf0[itemp+1] == '5') & ( send_buf0[itemp+2] == 'A') & ( send_
             -buf0[itemp+3] == 'A') & ( send_buf0[itemp+4] == 'F') & ( send_buf0[itemp+5] == 'F') )
 398   4                                      {
 399   5      
 400   5                                              addr=addr+6;
 401   5                                              if (( send_buf0[addr] == 'R') & ( send_buf0[addr+1] == 'E') & ( send_buf0[addr+2] == 'S') & ( send_bu
             -f0[addr+3] == 'E') & ( send_buf0[addr+4] == 'T'))
 402   5                                              {
 403   6                                                      reset=1;
 404   6                                              }
 405   5                                              else
 406   5                                              {
 407   6                                                      for ( i = 0 ; i < 6 ; i++ )
 408   6                                                      {
 409   7                                                              chtemp=send_buf0[addr];
 410   7                                                              chtemp=chtemp & 0x0f;
 411   7                                                              ch=chtemp<<4;
 412   7                                                              addr++;
 413   7                                                              chtemp=send_buf0[addr];
 414   7                                                              chtemp=chtemp & 0x0f;
 415   7                                                              ch=chtemp | ch;
 416   7                                                              sockset[i]=ch;
 417   7                                                              addr++;
 418   7                                                      }
 419   6                                                      p=&sockset[0];
 420   6                                                      i=x_server_port;
 421   6                                                      x_write(i,p,2);//write server port
 422   6                                                      p=&sockset[2];
 423   6                                                      i=x_server_addr;
 424   6                                                      x_write(i,p,4);//write server port
C51 COMPILER V7.20   5112UDP                                                               08/18/2004 10:31:57 PAGE 8   

 425   6                                                      set=1;
 426   6                                              }
 427   5                                              for ( i = smsindex ; i > 0 ; i -- ) //delete other all short messages
 428   5                                              {
 429   6                                                      send_ctr_com0_buf[0]='A';//delete short message
 430   6                                                      send_ctr_com0_buf[1]='T';
 431   6                                                      send_ctr_com0_buf[2]='+';
 432   6                                                      send_ctr_com0_buf[3]='C';
 433   6                                                      send_ctr_com0_buf[4]='M';
 434   6                                                      send_ctr_com0_buf[5]='G';
 435   6                                                      send_ctr_com0_buf[6]='D';
 436   6                                                      send_ctr_com0_buf[7]='=';
 437   6                                                      if ( i > 9 )
 438   6                                                      {
 439   7                                                              ch=i/10;
 440   7                                                              ch=ch+0x30;
 441   7                                                              send_ctr_com0_buf[8]=ch;
 442   7                                                              ch=i-(i/10)*10+0x30;
 443   7                                                              send_ctr_com0_buf[9]=ch;
 444   7                                                              chtemp=10;
 445   7                                                      }
 446   6                                                      else
 447   6                                                      {
 448   7                                                              send_ctr_com0_buf[8]=i+0x30;
 449   7                                                              chtemp=9;
 450   7                                                      }
 451   6                                                      send_ctr_com0_buf[chtemp]=0x0d;
 452   6                                                      chtemp++;
 453   6      
 454   6      
 455   6                                                      send_data0=0;
 456   6                                                      send_ctr_com0_len=chtemp;
 457   6                                                      send_com0_cnt=0;
 458   6                                                      send_com0_finish=0;
 459   6                                                      rcv_cnt0=0;
 460   6                                                      TI=1;
 461   6                                                      while ( ! send_com0_finish )
 462   6                                                      {
 463   7                                                      ;
 464   7                                                      }
 465   6                                                      wait(150);
 466   6                                                      wait(150);
 467   6                                                      DSP_SEND=1;
 468   6                                                      DSP_RCV=1;
 469   6                                                      wait(150);
 470   6                                                      wait(150);
 471   6                                                      DSP_SEND=0;
 472   6                                                      DSP_RCV=0;
 473   6                                                      wait(150);
 474   6                                                      wait(150);
 475   6                                                      wait(150);
 476   6                                              }
 477   5                                              while ( reset )
 478   5                                              {
 479   6                                              ;
 480   6                                              }
 481   5                                              break;
 482   5                                      }
 483   4                              }
 484   3                      }
 485   2                      if ( ! set )
 486   2                      {
C51 COMPILER V7.20   5112UDP                                                               08/18/2004 10:31:57 PAGE 9   

 487   3                              send_ctr_com0_buf[0]='A';//delete short message
 488   3                              send_ctr_com0_buf[1]='T';
 489   3                              send_ctr_com0_buf[2]='+';
 490   3                              send_ctr_com0_buf[3]='C';
 491   3                              send_ctr_com0_buf[4]='M';
 492   3                              send_ctr_com0_buf[5]='G';
 493   3                              send_ctr_com0_buf[6]='D';
 494   3                              send_ctr_com0_buf[7]='=';
 495   3                              if ( smsindex > 9 )
 496   3                              {
 497   4                                      ch=smsindex/10;
 498   4                                      ch=ch+0x30;
 499   4                                      send_ctr_com0_buf[8]=ch;
 500   4                                      ch=smsindex-(smsindex/10)*10+0x30;
 501   4                                      send_ctr_com0_buf[9]=ch;
 502   4                                      chtemp=10;
 503   4                              }
 504   3                              else
 505   3                              {
 506   4                                      send_ctr_com0_buf[8]=smsindex+0x30;
 507   4                                      chtemp=9;
 508   4                              }
 509   3                              send_ctr_com0_buf[chtemp]=0x0d;
 510   3                              chtemp++;
 511   3                              send_data0=0;
 512   3                              send_ctr_com0_len=chtemp;
 513   3                              send_com0_cnt=0;
 514   3                              send_com0_finish=0;
 515   3                              rcv_cnt0=0;
 516   3                              TI=1;
 517   3                              while ( ! send_com0_finish )
 518   3                              {
 519   4                              ;
 520   4                              }
 521   3                              wait(150);
 522   3                              wait(150);
 523   3                              DSP_SEND=1;
 524   3                              DSP_RCV=1;
 525   3                              wait(150);
 526   3                              wait(150);
 527   3                              DSP_SEND=0;
 528   3                              DSP_RCV=0;
 529   3                              wait(150);
 530   3                              wait(150);

⌨️ 快捷键说明

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