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

📄 photo.lst

📁 通过车载终端采集GPS数据
💻 LST
📖 第 1 页 / 共 2 页
字号:
 265   1          {
 266   2              //gnPhotoState == PHOTO_RETRYDATA
 267   2              Byte nStart, bFound = 0;
 268   2              if (0xffff == gnPhotoCurSeq)
 269   2                  gnPhotoCurSeq = 0;
 270   2              else
 271   2                  gnPhotoCurSeq++;
 272   2              nStart = gnPhotoCurSeq;
 273   2              photo_addretryThrd(1);
 274   2              for (i=nStart; i<gnPhotoRetryThrd; i++)
 275   2              {
 276   3                  if (gPhotoPacketstate[i] == PHOTO_PACK_WAITACK)
 277   3                  {
 278   4                      
 279   4                      bFound = 1;
 280   4                      break;
 281   4                  }                
 282   3              }
 283   2              gnPhotoCurSeq = i;
 284   2              if (0 == bFound)
 285   2              {
 286   3                  if (gnPhotoRetryThrd >= gnPhotoPackNum)
 287   3                  {
 288   4                      gnPhotoState = PHOTO_RETRYDATATIMING;
 289   4                      gnPhotoCurSeq = 0xffff;
 290   4                      gnPhotoRetryThrd = gnPhotoPackNum;
 291   4                      gnPhotoTimeout = PHOTO_TIMEOUT;
 292   4                  }
 293   3                  return INVALID_DATA;
 294   3              }
 295   2              return VALID_DATA;        
 296   2          }
 297   1      }
 298          
 299          //接收模块
 300          
 301          void photo_recievepro()
C51 COMPILER V7.09   PHOTO                                                                 08/22/2008 14:26:52 PAGE 6   

 302          {
 303   1          Uint16 recLen;
 304   1          Byte* pRecBuf;
 305   1          Byte type;
 306   1          Uint16 nTmp16;
 307   1          recLen = siob_receive(&pRecBuf);
 308   1          
 309   1          type = PHOTO_ERRORPACKET;
 310   1          if (0 == recLen)
 311   1          {
 312   2              if (PHOTO_RECIEVEINIAL == gnPhotoState)
 313   2              {
 314   3                  gnPhotoRetry++;
 315   3                  if (gnPhotoRetry > 200)
 316   3                      gnPhotoState = PHOTO_NOPHOTO;
 317   3                  else if (0 == (gnPhotoRetry%20))
 318   3                      gnPhotoState = PHOTO_SENDINIAL;
 319   3                      
 320   3              }
 321   2              if ((PHOTO_PHOTOPACKET == gnPhotoState) || (PHOTO_RECIEVERETRYDATA == gnPhotoState) || (PHOTO_RECI
             -EVETIMINGDATA == gnPhotoState))
 322   2              {
 323   3                  gnPhotoRetry++;
 324   3                  if (gnPhotoRetry >= 20)
 325   3                  {
 326   4                      gnPhotoRetry = 0;
 327   4                      photo_sendpacket(gPhotoSendBuf, PHOTO_PHOTODATAREQ, gnPhotoCurSeq);
 328   4                  }
 329   3              }
 330   2              return;    
 331   2          }
 332   1      
 333   1          if (12 == recLen)
 334   1          {
 335   2              if (PHOTO_RECIEVEINIAL == gnPhotoState)
 336   2              {
 337   3                  if (0x0d == pRecBuf[2])
 338   3                  {
 339   4                      gnPhotoState = PHOTO_SETFORMAT;
 340   4                      photo_sendpacket(gPhotoSendBuf, PHOTO_RESPONSEINIAL, 0);
 341   4                  }
 342   3                  else
 343   3                  {
 344   4                      gnPhotoRetry++;
 345   4                      if (gnPhotoRetry > 200)
 346   4                          gnPhotoState = PHOTO_NOPHOTO;
 347   4                      else if (0 == (gnPhotoRetry%20))
 348   4                          gnPhotoState = PHOTO_SENDINIAL;
 349   4                  }
 350   3                  
 351   3                   
 352   3              } 
 353   2              else if (PHOTO_RECIEVEGETPHOTODATA == gnPhotoState)
 354   2              {
 355   3                  Uint32 nTmp32;
 356   3                  nTmp32 = pRecBuf[9]+pRecBuf[10]*0x100+pRecBuf[11]*0x10000;
 357   3                  if (0 == (nTmp32 % (gnPhotoSize-6)))
 358   3                      gnPhotoPackNum = nTmp32/(gnPhotoSize-6);
 359   3                  else
 360   3                      gnPhotoPackNum = nTmp32/(gnPhotoSize-6)+1;
 361   3                  gnPhotoState = PHOTO_PHOTOPACKET;
 362   3                  gnPhotoCurSeq = 0;
C51 COMPILER V7.09   PHOTO                                                                 08/22/2008 14:26:52 PAGE 7   

 363   3                  photo_sendpacket(gPhotoSendBuf, PHOTO_PHOTODATAREQ, gnPhotoCurSeq);
 364   3                  gnPhotoDataSending = PHOTO_DATASENDING;
 365   3              }
 366   2              siob_start_receive();
*** WARNING C206 IN LINE 366 OF EXTENDUART\PHOTO.C: 'siob_start_receive': missing function-prototype
 367   2              return;
 368   2              
 369   2          }
 370   1          
 371   1          siob_start_receive();
 372   1          if (6 == recLen)
 373   1          {
 374   2              if (0xaa != pRecBuf[0])
 375   2                  return;
 376   2      
 377   2              if (0x0e == pRecBuf[1])
 378   2              {
 379   3                  //为应答包
 380   3                  for (nTmp16=0; nTmp16<PHOTO_RESPONSE_NUM; nTmp16++)
 381   3                  {
 382   4                      if (pRecBuf[2] == gPhotoResp[nTmp16])
 383   4                          break;
 384   4                  }
 385   3                  if (nTmp16 >= PHOTO_RESPONSE_NUM)
 386   3                      type = PHOTO_ERRORPACKET; 
 387   3                  else
 388   3                      type = nTmp16;
 389   3              }
 390   2              else
 391   2              {
 392   3                  //接收摄像头主动发送的包
 393   3                  if (pRecBuf[1] == 0x0d)
 394   3                      type = PHOTO_REQ_PHOTOINIAL;
 395   3                  else if ((pRecBuf[1] == 0x0a) && (pRecBuf[2] == 0x01))
 396   3                      type = PHOTO_REQ_PHOTOSIZE;
 397   3                  else  
 398   3                      type = PHOTO_ERRORPACKET;
 399   3              }
 400   2          }
 401   1          else if (recLen > 6)
 402   1          {
 403   2              if (PHOTO_DATASENDING == gnPhotoDataSending)
 404   2              {
 405   3                  //接收相片数据
 406   3                  if ((pRecBuf[0] == LSB(gnPhotoCurSeq)) && (pRecBuf[1] == MSB(gnPhotoCurSeq)))
 407   3                  {
 408   4                      //检查校验
 409   4                      Byte sum = 0;
 410   4                  
 411   4                      for (nTmp16=0; nTmp16<(recLen-2); nTmp16++)
 412   4                          sum += pRecBuf[nTmp16];
 413   4                      if (sum == pRecBuf[recLen-2])
 414   4                      {
 415   5                          //进行转发
 416   5                          Uint16 nTmpLen;
 417   5                          nTmpLen = pRecBuf[2]+pRecBuf[3]*0x100;
 418   5                          make_photo_message(gnPhotoPackNum, gnPhotoCurSeq+1, gphoto_msgnum, pRecBuf+4, nTmpLen)
             -;
 419   5          //                sprintf(testBuf, "%4d:%4d:%4d\r\n", gnPhotoPackNum, gnPhotoCurSeq, nTmpLen);//here a
             -aa
 420   5          //                sioc_send(testBuf, strlen(testBuf));//here aaa
 421   5                                 
C51 COMPILER V7.09   PHOTO                                                                 08/22/2008 14:26:52 PAGE 8   

 422   5                      }
 423   4                  }
 424   3           //       photo_sendpacket(gPhotoSendBuf, PHOTO_PHOTODATAREQ, gnPhotoCurSeq);
 425   3                  gnPhotoRetry = PHOTO_GPRSTIMEOUT;
 426   3                  gnPhotoState -= PHOTOSTATE_THRD;
 427   3                  return;
 428   3              }
 429   2              
 430   2          }
 431   1      
 432   1          if (PHOTO_RECIEVEFORMAT == gnPhotoState)
 433   1          {
 434   2              if (type == PHOTO_RET_MODE)
 435   2              {    
 436   3                  gnPhotoRetry = 0;
 437   3                  gnPhotoState = PHOTO_SETPACKETSIZE;
 438   3              }
 439   2          }
 440   1          else if (PHOTO_RECIEVEPACKETSIZE == gnPhotoState)
 441   1          {
 442   2              if (type == PHOTO_RET_PACKETSIZE)
 443   2                  gnPhotoState = PHOTO_WAITCOMMAND;//for test PHOTO_QUICKSNAP;// 
 444   2          }
 445   1          else if (PHOTO_RECIEVEQUICKSNAP == gnPhotoState)
 446   1          {
 447   2               if (type == PHOTO_RET_SNAP)
 448   2                  gnPhotoState = PHOTO_GETPHOTODATA;
 449   2          }
 450   1          else if (PHOTO_RECIEVEGETPHOTODATA == gnPhotoState)
 451   1          {
 452   2              if (type == PHOTO_RET_DATA)
 453   2                  gnPhotoState = PHOTO_PHOTOSNAP;
 454   2          }
 455   1          else if (PHOTO_PHOTOSNAP == gnPhotoState)
 456   1          {
 457   2              if (type == PHOTO_REQ_PHOTOSIZE)
 458   2              {
 459   3                  Uint32 nTmp32;
 460   3                  nTmp32 = pRecBuf[3]+pRecBuf[4]*0x100+pRecBuf[5]*0x10000;
 461   3                  if (0 == (nTmp32 % (gnPhotoSize-6)))
 462   3                      gnPhotoPackNum = nTmp32/(gnPhotoSize-6);
 463   3                  else
 464   3                      gnPhotoPackNum = nTmp32/(gnPhotoSize-6)+1;
 465   3                  gnPhotoState = PHOTO_PHOTOPACKET;
 466   3                  gnPhotoCurSeq = 0;
 467   3                  photo_sendpacket(gPhotoSendBuf, PHOTO_PHOTODATAREQ, gnPhotoCurSeq);
 468   3              }
 469   2          }
 470   1      }
 471          
 472          /*nValue: 值从0开始***/
 473          void photo_setPacketState(Byte nValue)
 474          {
 475   1      //    sprintf(testBuf, "\r\n%bd\r\n", nValue);//here aaa
 476   1      //    sioc_send(testBuf, strlen(testBuf));//here aaa
 477   1          gPhotoPacketstate[nValue] = PHOTO_PACK_NOUSE;
 478   1      }
 479          
 480          void photostart_photo(Byte* pMsgNum)
 481          {   
 482   1          Byte i;
 483   1          if (memcmp(pMsgNum, gphoto_msgnum, 4) != 0)
C51 COMPILER V7.09   PHOTO                                                                 08/22/2008 14:26:52 PAGE 9   

 484   1          {    
 485   2              memcpy(gphoto_msgnum, pMsgNum, 4);
 486   2      //        sprintf(testBuf, "everything22 is ok");
 487   2      //        sioc_send(testBuf, strlen(testBuf));
 488   2              for (i=0; i<PHOTO_PACK_NUM; i++)
 489   2                  gPhotoPacketstate[i] = PHOTO_PACK_WAITACK;
 490   2              if (PHOTO_NOPHOTO != gnPhotoState)
 491   2              {
 492   3                  if (PHOTO_DATASENDING == gnPhotoDataSending)
 493   3                  {
 494   4                      gnPhotoRetry = PHOTO_REPHOTOTIMEOUT;
 495   4                      gnPhotoState = PHOTO_PHOTODATAOVER;
 496   4                  }
 497   3                  else
 498   3                      gnPhotoState = PHOTO_QUICKSNAP;
 499   3              }
 500   2          }
 501   1      }
 502          
 503          void photo_stopphoto()
 504          {
 505   1          Byte i;
 506   1      //    sprintf(testBuf, "everything33 is ok");
 507   1      //    sioc_send(testBuf, strlen(testBuf));
 508   1          for (i=0; i<PHOTO_PACK_NUM; i++)
 509   1              gPhotoPacketstate[i] = PHOTO_PACK_NOUSE;
 510   1          if (PHOTO_DATASENDING == gnPhotoDataSending)
 511   1          {
 512   2              gnPhotoDataSending = PHOTO_NODATASEND;
 513   2              gnPhotoState = PHOTO_PHOTODATAOVER;
 514   2          }
 515   1      }
 516          
 517          Byte photo_getdatastatus()
 518          {
 519   1          return gnPhotoDataSending;
 520   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2564    ----
   CONSTANT SIZE    =     47    ----
   XDATA SIZE       =    772      23
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  1 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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