GpsProcess.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /**********************************************************************************
  2. * File Name: GpsProcess.c
  3. * Function Describe:device for Gps Process
  4. * Relate Module:
  5. * Explain:
  6. * Writer: ShiLiangWen
  7. * Date: 2015.1.26
  8. ***********************************************************************************/
  9. #define THIS_FILE_ID 11
  10. //-------------------------------------------------------------------------------------------
  11. #include "includes.h"
  12. SUT_GPS_SEND_DATA sutGpsSendData;
  13. /**********************************************************************************
  14. GpsSendHead
  15. ***********************************************************************************/
  16. void GpsServerConect(void)
  17. { //"AT+ZIPSEND=0,12\r"=41542B5A495053454E443D302C31320D
  18. //"AT+ZIPSENDU=0,12\r"=41542B5A495053454E44553D302C31320D
  19. //unsigned char Data[]={0x29,0x29,0xB1,0x00,0x07,0x59,0x69,0xB5,0xA1,0x00,0x92,0x0D}; //2929B100075969B5A100920D
  20. //ModemSendAT("AT+ZIPSEND=0,12\r"); //41542B5A495053454E443D302C31320D2929B100075969B5A100920D
  21. //ModemSendData(Data,sizeof(Data));
  22. int len;
  23. unsigned char buf[100];
  24. unsigned char temp=0;
  25. len=GpsPacket(buf,sutProductPara.PSN,XINGAN_PACKET_CLIENT_CMD_CONNECT,&temp,1);
  26. // if(WCDMA){
  27. // ModemSendTcpData(1,buf,len);//+ 1? WCDMA
  28. // }else{
  29. // ModemSendTcpData(0,buf,len);
  30. // }
  31. if(MODEM_TYPE==MODEM_TYPE_MW3650){
  32. MW3650ModemSendTcpData(1,buf,len);
  33. }else if(MODEM_TYPE==MODEM_TYPE_MC8332){
  34. MC8332ModemSendTcpData(0,buf,len);
  35. }
  36. }
  37. unsigned char GetCheckSum(unsigned char *pData,int len)
  38. {
  39. int i;
  40. unsigned char sum=0;
  41. for(i=0;i<len;i++){
  42. sum=sum^pData[i];
  43. }
  44. return sum;
  45. }
  46. /*************************************************************************************
  47. *
  48. **************************************************************************************/
  49. int GpsPacket(unsigned char *Buffer,unsigned long PSN,unsigned char CMD,unsigned char *pData,int DataLen)
  50. {
  51. unsigned char *pBuf=Buffer;
  52. int j,i=0;
  53. unsigned short Len=DataLen+6;
  54. pBuf[i++]=0x29;
  55. pBuf[i++]=0x29;
  56. pBuf[i++]=CMD;
  57. pBuf[i++]=(unsigned char)((Len>>8)&0xff);
  58. pBuf[i++]=(unsigned char)(Len&0xff);
  59. pBuf[i++]=(unsigned char)((PSN>>24)&0xff);
  60. pBuf[i++]=(unsigned char)((PSN>>16)&0xff);
  61. pBuf[i++]=(unsigned char)((PSN>>8)&0xff);
  62. pBuf[i++]=(unsigned char)(PSN&0xff);
  63. for(j=0;j<DataLen;j++){
  64. pBuf[i++]= pData[j];
  65. }
  66. pBuf[i]=GetCheckSum(pBuf,i);
  67. i++;
  68. pBuf[i++]=0x0D;
  69. return i;
  70. }
  71. /**********************************************************************************
  72. GpsSendPosition
  73. 发送位置数据
  74. Head(2) Cmd(1) Len(2) PSN(4) GpsData(34) Check(1) End(1)
  75. Cmd=0x80
  76. 总长度=2+1+2+40=45
  77. ***********************************************************************************/
  78. void GpsSendPosition(void)
  79. {
  80. int i;
  81. int len;
  82. char tmp[5];
  83. char buf[150];
  84. unsigned char GpsBuf[50];
  85. len=GpsPacket(GpsBuf,sutProductPara.PSN,0x80,(unsigned char *)&sutGpsSendData,sizeof(SUT_GPS_SEND_DATA));
  86. // if(WCDMA){
  87. //// sprintf(buf,"AT+ZIPSEND=0,%d\r",len);
  88. // sprintf(buf,"AT^IPSEND=1,%d\r",len);//+ 1? WCDMA
  89. // }else{
  90. // sprintf(buf,"AT+ZIPSEND=0,%d\r",len);
  91. // }
  92. if(MODEM_TYPE==MODEM_TYPE_MW3650){
  93. sprintf(buf,"AT^IPSEND=1,%d\r",len);
  94. }else if(MODEM_TYPE==MODEM_TYPE_MC8332){
  95. sprintf(buf,"AT+ZIPSEND=0,%d\r",len);
  96. }
  97. ModemSendAT(buf);
  98. ModemSendData(GpsBuf,len);
  99. strcpy(buf,"SendGpsD:");
  100. for(i=0;i<len;i++){
  101. sprintf(tmp,"%02x,",GpsBuf[i]);
  102. strcat(buf,tmp);
  103. }
  104. strcat(buf,"\r\n");
  105. SlwTrace(INF,buf);
  106. }
  107. /*******************************************************
  108. GPRMC信息,与,之间的子信息处理,存储到相应的结构体中元素中
  109. *******************************************************/
  110. void GPS_GPRMC_Handle(unsigned char *ch,unsigned char ch1)
  111. {
  112. unsigned char x,y;
  113. // send_byte('d');
  114. switch(ch1)
  115. {
  116. case 0: //时间
  117. for(x=0,y=0;x<8;x++)
  118. {
  119. if(x==2||x==5){ sutGpsInfo.Time[x]=0x3a;}
  120. else sutGpsInfo.Time[x]=ch[y++];
  121. }
  122. // send_byte(time[7]);
  123. break;
  124. case 1: //状态
  125. sutGpsInfo.Status=ch[0];
  126. break;
  127. case 2: //纬度
  128. for(x=10,y=0;x<17;x++)
  129. {
  130. if(x==12||x==15) {}
  131. else sutGpsInfo.Location[x]=ch[y++];
  132. }
  133. break;
  134. case 3: //南北纬
  135. sutGpsInfo.Location[9]=ch[0];
  136. break;
  137. case 4: //经度
  138. for(x=1,y=0;x<8;x++){
  139. if(x==4||x==7){}
  140. else sutGpsInfo.Location[x]=ch[y++];
  141. }
  142. break;
  143. case 5: //东西经
  144. sutGpsInfo.Location[0]=ch[0];
  145. break;
  146. case 6: //航速
  147. for(x=0;x<6;x++){
  148. sutGpsInfo.Speed[x+1]=ch[x];
  149. }
  150. sutGpsInfo.Speed[6]=0x20;
  151. sutGpsInfo.Speed[7]=0x20;
  152. break;
  153. case 7: //信息自己定义
  154. break;
  155. case 8: //信息自己定义
  156. break;
  157. case 9: //信息自己定义
  158. break;
  159. case 10: //信息自己定义
  160. break;
  161. case 11: //信息自己定义
  162. break;
  163. default:break;
  164. }
  165. }
  166. /*******************************************************
  167. 处理GPRMC信息
  168. *******************************************************/
  169. void GPS_GPRMC_Alysis(char *RMC_Data)
  170. {
  171. unsigned char i,j,k;
  172. unsigned char count;
  173. unsigned char temp[10];
  174. //send_byte('a');
  175. for(i=0;i<strlen(RMC_Data);)
  176. {
  177. switch(RMC_Data[i])
  178. {
  179. case '$':
  180. j=i++; //标记$的起始位置
  181. while(RMC_Data[i]!=',') //RMC_Data[i]==','时结束循环。
  182. {i++;}
  183. // uart1_sendbytes(GPRMC[RMC_Count].RMC_ID);
  184. break;
  185. case ',':
  186. j=i++; //标记,的起始位置
  187. while((RMC_Data[i]!=',')&&(RMC_Data[i]!='*')) //RMC_Data[i]==','或者=='*'时结束循环。
  188. {i++;}
  189. if(j+1!=i)
  190. {
  191. for(j=j+1,k=0;j<i;j++)
  192. {
  193. temp[k++]=RMC_Data[j];
  194. }
  195. temp[k]='\0';
  196. // send_byte(temp[0]);
  197. }
  198. else temp[0]='\0';
  199. // send_byte('c');
  200. GPS_GPRMC_Handle(temp,count++);
  201. break;
  202. case '*':
  203. i=strlen(RMC_Data); //处理完成,软件结束。
  204. break;
  205. default:break;
  206. }
  207. }
  208. // send_byte('e');
  209. }
  210. void GpsDataInit(void)
  211. {
  212. unsigned char *p;
  213. p=(unsigned char *)&sutGpsSendData;
  214. memset(p, 0, sizeof(SUT_GPS_SEND_DATA));
  215. p=(unsigned char *)&sutGpsInfo;
  216. memset(p, 0, sizeof(SUT_GPS_INF));
  217. switch(sutProductPara.m_GPS_SendTime)
  218. {
  219. case 0:case 10:case 15:case 30:case 60:
  220. break;
  221. default:
  222. sutProductPara.m_GPS_SendTime = 10;
  223. SaveProductParaToFlash();
  224. break;
  225. }
  226. sutGpsInfo.GPSSendTime = sutProductPara.m_GPS_SendTime;
  227. sutGpsInfo.SendTime = sutProductPara.m_GPS_SendTime;
  228. }
  229. /*************************************************************************
  230. *检查GPS 服务器发过来的数据包是否正确
  231. 非法 返回0
  232. 合法 返回命令码
  233. **************************************************************************/
  234. unsigned char GpsServerCheckPack(unsigned char *data,unsigned short DataLen)
  235. {
  236. int i=0;
  237. unsigned char cmd;
  238. unsigned short len;
  239. unsigned long PSN;
  240. //判断数据包的包头是否正确
  241. if(data[0]!=GPS_PACK_HEAD1)return 0;
  242. if(data[1]!=GPS_PACK_HEAD2)return 0;
  243. //判断数据包的校验是否正确
  244. if(data[DataLen-2] != GetCheckSum(data,DataLen-2))
  245. {
  246. return 0;
  247. }
  248. //判断数据包的结尾是否正确
  249. if(data[DataLen-1] != GPS_PACK_END)
  250. {
  251. return 0;
  252. }
  253. //获取数据包的长度 并判断长度是否正确
  254. len=(unsigned short)data[3]*256+data[4];
  255. if(DataLen!=(len+5))return 0;
  256. // //判断终端编号是否正确
  257. // PSN=(unsigned long)data[5]<<24;
  258. // PSN+=(unsigned long)data[6]<<16;
  259. // PSN+=(unsigned long)data[7]<<8;
  260. // PSN+=(unsigned long)data[8];
  261. // if(PSN!=sutNetPara.PSN) return 0;
  262. //解析当前命令
  263. cmd = data[2];
  264. sutGpsInfo.HostCmd = cmd;
  265. return cmd;
  266. }
  267. /**************************************************************************************************
  268. *
  269. ***************************************************************************************************/
  270. uint32_t Process_XinganCenterGetPos_rsp(unsigned char* buf, unsigned short len)
  271. {
  272. unsigned char SendBuf[100];
  273. unsigned short PacketLen;
  274. MakeGpsSendData();
  275. PacketLen=GpsPacket(SendBuf,sutProductPara.PSN,XINGAN_PACKET_CENTER_CMD_GET_POS_RSP,(unsigned char *)&sutGpsSendData,sizeof(SUT_GPS_SEND_DATA));
  276. // if(WCDMA){
  277. // ModemSendTcpData(1,SendBuf,PacketLen);//+ 1? WCDMA
  278. // }else{
  279. // ModemSendTcpData(0,SendBuf,PacketLen);
  280. // }
  281. if(MODEM_TYPE==MODEM_TYPE_MW3650){
  282. MW3650ModemSendTcpData(1,SendBuf,PacketLen);
  283. }else if(MODEM_TYPE==MODEM_TYPE_MC8332){
  284. MC8332ModemSendTcpData(0,SendBuf,PacketLen);
  285. }
  286. return 0;
  287. }
  288. uint32_t Process_XinganClient_rsp(char* buf, unsigned short len)
  289. {
  290. if(!sutGpsInfo.isServerLogin){
  291. sutGpsInfo.isServerLogin=1;
  292. SlwTrace(INF,"[Gps Logined]\r\n");
  293. }
  294. return 0;
  295. }
  296. /**************************************************************************************************
  297. *
  298. ***************************************************************************************************/
  299. void GpsTimingSendPos(void)
  300. {
  301. unsigned char SendBuf[100];
  302. unsigned short PacketLen;
  303. //if(sutGpsInfo.isGpsWork==0)return;
  304. MakeGpsSendData();
  305. PacketLen=GpsPacket(SendBuf,sutProductPara.PSN,XINGAN_PACKET_CLIENT_SEND_POS_DATA,(unsigned char *)&sutGpsSendData,sizeof(SUT_GPS_SEND_DATA));
  306. // if(WCDMA){
  307. // ModemSendTcpData(1,SendBuf,PacketLen);//+ 1? WCDMA
  308. // }else{
  309. // ModemSendTcpData(0,SendBuf,PacketLen);
  310. // }
  311. if(MODEM_TYPE==MODEM_TYPE_MW3650){
  312. MW3650ModemSendTcpData(1,SendBuf,PacketLen);
  313. }else if(MODEM_TYPE==MODEM_TYPE_MC8332){
  314. MC8332ModemSendTcpData(0,SendBuf,PacketLen);
  315. }
  316. return ;
  317. }
  318. /***********************************************************************************
  319. *服务器设置主动上报时间
  320. *数据格式
  321. HEAD1 HEAD2 CMD LEN1 LEN2 PSN1 PSN2 PSN3 PSN4 X1 X2 CHECK END
  322. 29 29 34 00 08 PSN[4] X1 X2 CHECK 0D
  323. time=X1*256+X2
  324. ***********************************************************************************/
  325. uint32_t Process_XinganCenterGetPosTimerout(char* buf, uint32_t len)
  326. {
  327. char SendBuf[100];
  328. unsigned short t;
  329. unsigned short PacketLen;
  330. //跳过终端序列号4 bytes
  331. //获取时间
  332. sutGpsInfo.SendTime =((unsigned short)buf[9]&0xff<<8) + (unsigned short)buf[10]&0xff ;
  333. sprintf(SendBuf,"[GpsTime=%d]\r\n",sutGpsInfo.SendTime);
  334. SlwTrace(INF,SendBuf);
  335. //ol_start_AppTimer( XINGAN_SENDBACK_TIMER, g_xingan_info.timeout * KAL_TICKS_1_SEC);
  336. MakeGpsSendData();
  337. PacketLen=GpsPacket(SendBuf,sutProductPara.PSN,XINGAN_PACKET_CENTER_CMD_COMMON_RSP,(unsigned char *)&sutGpsSendData,sizeof(SUT_GPS_SEND_DATA));
  338. // if(WCDMA){
  339. // ModemSendTcpData(1,SendBuf,PacketLen);//+ 1? WCDMA
  340. // }else{
  341. // ModemSendTcpData(0,SendBuf,PacketLen);
  342. // }
  343. if(MODEM_TYPE==MODEM_TYPE_MW3650){
  344. MW3650ModemSendTcpData(1,SendBuf,PacketLen);
  345. }else if(MODEM_TYPE==MODEM_TYPE_MC8332){
  346. MC8332ModemSendTcpData(0,SendBuf,PacketLen);
  347. }
  348. return len;
  349. }
  350. /******************************************************************************
  351. *
  352. *******************************************************************************/
  353. XinganCmd_struct XinganCmd_info[] =
  354. {
  355. {XINGAN_PACKET_CENTER_CMD_GET_POS, Process_XinganCenterGetPos_rsp},
  356. // {XINGAN_PACKET_CENTER_CMD_GET_STAT, Process_XinganCenterGetStat_rsp},
  357. // {XINGAN_PACKET_CENTER_CMD_RESET, Process_XinganCenterReset_rsp},
  358. // {XINGAN_PACKET_CENTER_CMD_DEFAULT_SET, Process_XinganCenterDefaultSet_rsp},
  359. {XINGAN_PACKET_CENTER_CMD_GET_POS_TIMEOUT, Process_XinganCenterGetPosTimerout},
  360. // {XINGAN_PACKET_CENTER_CMD_GET_POS_LENOUT, Process_XinganCenterGetPosLenout},
  361. // {XINGAN_PACKET_CENTER_CMD_CLOSE_WARNING, Process_XinganCenterCloseWarning_rsp},
  362. // {XINGAN_PACKET_CENTER_CMD_OPEN_OIL_WAY, Process_XinganCenterOpenOilWay_rsp},
  363. // {XINGAN_PACKET_CENTER_CMD_CLOSE_OIL_WAY, Process_XinganCenterCloseOilWay_rsp},
  364. // {XINGAN_PACKET_CENTER_CMD_GET_VER, Process_XinganCenterGetVer_rsp},
  365. // {XINGAN_PACKET_CENTER_CMD_DIAL_CALL, Process_XinganCenterDialCall_rsp} ,
  366. // {XINGAN_PACKET_CENTER_CMD_HIGH_SPEED_WARNING, Process_XinganCenterHighSpeedWarning_rsp},
  367. // {XINGAN_PACKET_CENTER_CMD_STATISTICS_MILE, Process_XinganCenterStatisticsMile_rsp},
  368. // {XINGAN_PACKET_CENTER_CMD_UDP_IPPORT, Process_XinganCenterIPport_rsp},
  369. // {XINGAN_PACKET_CENTER_CMD_APN, Process_XinganCenterApn_rsp},
  370. //
  371. {XINGAN_PACKET_CLIENT_CMD_COMMON_RSP, Process_XinganClient_rsp},
  372. //
  373. // {XINGAN_PACKET_CLIENT_CMD_CONNECT, Process_XinganClientConnectReq},
  374. // {XINGAN_PACKET_CLIENT_SEND_POS_DATA, Process_XinganClientSendPosData},
  375. // {XINGAN_PACKET_CLIENT_CMD_SEND_WARNING_DATA, Process_XinganClientSendWarnData},
  376. };
  377. Xingan_process_packet GetXinganProcessFun(uint32_t Cmd)
  378. {
  379. uint32_t j;
  380. for(j=0;j<sizeof(XinganCmd_info)/sizeof(XinganCmd_struct);j++)
  381. {
  382. if(Cmd == XinganCmd_info[j].cmd)
  383. {
  384. return XinganCmd_info[j].process_packet;
  385. }
  386. }
  387. return NULL;
  388. }
  389. /***************************************************************
  390. 处理GPS服务器发过来的信息
  391. 返回:
  392. 无效消息 不处理 返回0
  393. 否则返回命令码
  394. ****************************************************************/
  395. unsigned char GpsServerProcess(unsigned char *data, unsigned short DataLen)
  396. {
  397. unsigned char cmd;
  398. Xingan_process_packet ProcessFun;
  399. cmd=GpsServerCheckPack(data,DataLen);
  400. if(!cmd)return 0;
  401. ProcessFun = GetXinganProcessFun(cmd);
  402. if(ProcessFun !=NULL)
  403. {
  404. ProcessFun(data, DataLen);
  405. }
  406. return cmd;
  407. }
  408. //#define GPS_DEBUG_GPS_SEND_DATA //////////////////////////////打开它会锁死定位
  409. /***************************************************************************
  410. *MakeGpsSendData
  411. 根据sutGpsInfo生成sutGpsSendData
  412. ****************************************************************************/
  413. void MakeGpsSendData(void)
  414. {
  415. #ifdef GPS_DEBUG_GPS_SEND_DATA
  416. int i;
  417. const unsigned char acucTemp[]={
  418. 0x15,0x07,0x25,0x15,0x41,0x18,//yymmddhhmmss
  419. 0x02,0x23,0x75,0x49, //wwww 纬度
  420. 0x11,0x40,0x13,0x22, //jjjj 经度
  421. 0x00,0x07,0x01,0x28, //ssff 速度方向
  422. 0xf8,//st 状态
  423. 0x01,0xE2,0x40,//里程数 1E240=123456米
  424. 0x00,0x00,0x7f,//车辆状态 St1~St4
  425. 0x00,0x00,0x05,0x00,0x00,0x00,0x01,0x00,//V1~V8
  426. };
  427. unsigned char *p=(unsigned char *)&sutGpsSendData;
  428. for(i=0;i<sizeof(acucTemp);i++){
  429. p[i]=acucTemp[i];
  430. }
  431. #else
  432. unsigned char *data=(unsigned char *)&sutGpsSendData;
  433. memset(data, 0, sizeof(SUT_GPS_SEND_DATA));
  434. data[0] = sutGpsInfo.year;
  435. data[1] = sutGpsInfo.month;
  436. data[2] = sutGpsInfo.day;
  437. data[3] = sutGpsInfo.hour;
  438. data[4] = sutGpsInfo.minu;
  439. data[5] = sutGpsInfo.sec;
  440. data[6] = (sutGpsInfo.latitue>>24)&0xFF;
  441. data[7] = (sutGpsInfo.latitue>>16)&0xFF;
  442. data[8] = (sutGpsInfo.latitue>>8)&0xFF;
  443. data[9] = (sutGpsInfo.latitue)&0xFF;
  444. data[10] = (sutGpsInfo.longitue>>24)&0xFF;
  445. data[11] = (sutGpsInfo.longitue>>16)&0xFF;
  446. data[12] = (sutGpsInfo.longitue>>8)&0xFF;
  447. data[13] = (sutGpsInfo.longitue)&0xFF;
  448. data[14] = (sutGpsInfo.speed>>8)&0xFF;
  449. data[15] = (sutGpsInfo.speed)&0xFF;
  450. data[16] = (sutGpsInfo.aspect>>8)&0xFF;
  451. data[17] = (sutGpsInfo.aspect)&0xFF;
  452. //st;
  453. if(sutGpsInfo.isGpsWork==1 && sutGpsInfo.isGpsValid == 1){
  454. data[18] = 0x80;
  455. }
  456. /*
  457. if(sutGpsInfo.isGpsValid == 1 )
  458. {
  459. data[18] |= (0x01<<7);
  460. }
  461. if(sutGpsInfo.isGpsValid == 0)
  462. {
  463. data[18] |= (0x01<<6);
  464. data[18] |= (0x01<<5);
  465. }
  466. else if(sutGpsInfo.isGpsValid == 0)//:GPS天线短路
  467. {
  468. data[18] |= (0x01<<6);
  469. }
  470. else if(sutGpsInfo.isGpsValid == 0)//:GPS天线开路;
  471. {
  472. data[18] |= (0x01<<5);
  473. }
  474. else if(sutGpsInfo.isGpsValid == 0) //0x03:GPS模块故障
  475. {
  476. }
  477. */
  478. // if(sutGpsInfo.MainPowerStat ==0 )//主电源正常
  479. // {
  480. // data[18] |= (0x01<<4);
  481. // data[18] |= (0x01<<3);
  482. // }
  483. // else if(sutGpsInfo.MainPowerStat == 1)//主电源掉电
  484. // {
  485. // data[18] |= (0x01<<4);
  486. // }
  487. // else if(sutGpsInfo.MainPowerStat == 2 || g_xingan_info.MainPowerStat ==3)//主电源过高或过低
  488. // {
  489. // data[18] |= (0x01<<3);
  490. // }
  491. //里程数
  492. data[19] = (sutGpsInfo.StatisticsMile>>16)&0xFF;
  493. data[20] = (sutGpsInfo.StatisticsMile>>8)&0xFF;
  494. data[21] = (sutGpsInfo.StatisticsMile)&0xFF;
  495. //St1:
  496. // if(GetAccStat() == FALSE)//ACC关
  497. // {
  498. // data[22] |= (0x01<<7);
  499. // }
  500. // if(GetHighSensor1Stat() == FALSE)//自定义1路高传感器状态为低
  501. // {
  502. // data[22] |= (0x01<<6);
  503. // }
  504. // if(GetHighSensor2Stat() == FALSE)//自定义2路高传感器状态为低
  505. // {
  506. // data[22] |= (0x01<<5);
  507. // }
  508. // if(GetLowSensor1Stat() == TRUE)//自定义1路低传感器状态为高
  509. // {
  510. // data[22] |= (0x01<<4);
  511. // }
  512. // if(GetLowSensor2Stat()== TRUE)//自定义2路低传感器状态为高
  513. // {
  514. // data[22] |= (0x01<<3);
  515. // }
  516. //
  517. // if(GetOilWayStat()== TRUE)//油路正常
  518. // {
  519. // data[22] |= (0x01<<2);
  520. // }
  521. //
  522. // if(GetLoginStat() == FALSE)//没有登签
  523. // {
  524. // data[22] |= (0x01<<1);
  525. // }
  526. //
  527. // if(GetWarningStat() == FALSE)//未设防
  528. // {
  529. // data[22] |= (0x01);
  530. // }
  531. //st2:
  532. // if(GetRobWarningStat()== FALSE)//不为劫警报警
  533. // {
  534. // data[23] |= (0x01<<7);
  535. // }
  536. //
  537. // if(GetHighSpeedWarningStat()== FALSE)//不为超速报警
  538. // {
  539. // data[23] |= (0x01<<6);
  540. // }
  541. // if(GetStopTimeoutStat()== FALSE)//不为停车超长报警
  542. // {
  543. // data[23] |= (0x01<<5);
  544. // }
  545. // if(GooutOfRegion()== FALSE)//不为驶出区域报警
  546. // {
  547. // data[23] |= (0x01<<4);
  548. // }
  549. // if(ComeintoRegion()==FALSE)//不为驶入区域报警
  550. // {
  551. // data[23] |= (0x01<<3);
  552. // }
  553. //
  554. // if(PasswordIsOK()== TRUE)//不为看车密码错误报警
  555. // {
  556. // data[23] |= (0x01<<2);
  557. // }
  558. //
  559. // if(GprsIsLogin() == FALSE)//不为GPRS已上线
  560. // {
  561. // data[23] |= (0x01<<1);
  562. // }
  563. //
  564. // if(PppIsOK() == FALSE)//不为终端拨号成功
  565. // {
  566. // data[23] |= (0x01);
  567. // }
  568. //st3:
  569. // if(GprsIsLogin() == FALSE)//GPRS未注册
  570. // {
  571. // data[24] |= (0x01<<7);
  572. // }else{
  573. data[24] &= ~(0x01<<7);
  574. // }
  575. // if(CenterNeedSendCmd21() == TRUE)//中心应下发21指令
  576. // {
  577. data[24] |= (0x01<<6);
  578. // }
  579. // if(g_xingan_info.SendMode == XINGAN_PACKET_SEND_TCP)//TCP通讯方式
  580. // {
  581. data[24] |= (0x01<<5);
  582. // }
  583. //:CSQ信号状态0-31
  584. data[24] += (char)g_iCSQ;
  585. //st4
  586. // if(IsHandleOK()== TRUE)//手柄接入
  587. // {
  588. // data[25] |= (0x01<<7);
  589. // }
  590. // if(IsLcdOK() == TRUE)//LCD显示屏接入
  591. // {
  592. // data[25] |= (0x01<<6);
  593. // }
  594. // if(IsImageCollectorOK()== TRUE)//图像采集器接入
  595. // {
  596. // data[25] |= (0x01<<5);
  597. // }
  598. // if(IsFareMeterOK()== TRUE)//计价器接入
  599. // {
  600. // data[25] |= (0x01<<4);
  601. // }
  602. // if(IsVoiceDialerOK()==TRUE)//语音波号器接入
  603. // {
  604. // data[25] |= (0x01<<3);
  605. // }
  606. // if(IsForbiddenDialCall()==TRUE)//禁止打出
  607. // {
  608. // data[25] |= (0x01<<2);
  609. // }
  610. // if(IsForbiddenReceiveCall()==TRUE)//禁止打入
  611. // {
  612. // data[25] |= (0x01<<1);
  613. // }
  614. // if(IsForbiddenAllCalls()==TRUE)//禁止通话
  615. // {
  616. // data[25] |= (0x01);
  617. // }
  618. //v1v2v3v4:终端设置状态
  619. //V1V2:定时发送时间
  620. data[26] = (sutGpsInfo.SendTime>>8)&0xFF;
  621. data[27] = (sutGpsInfo.SendTime)&0xFF;
  622. //V3: 停车设置时间
  623. //data[28]= sutGpsInfo.StopTimeout&0xFF;
  624. //V4: 超速设置时间
  625. // data[29]= sutGpsInfo.HighSpeed;
  626. //V5; 电子围栏设置个数
  627. // data[30]= sutGpsInfo.ElectronicFenceNum;
  628. //V6: 登签
  629. if(sutGpsInfo.isServerLogin)data[31] = 1;
  630. else data[31] = 0;
  631. //: 定时发送图片的时间
  632. data[32] = 0;//
  633. //: 中心下发的主命令
  634. data[33]= sutGpsInfo.HostCmd;
  635. #endif
  636. }
  637. /*
  638. void MakeGpsData(void)
  639. {
  640. unsigned char *data=(unsigned char *)&sutGpsSendData;
  641. if(!sutGpsInfo.isGpsValid)return;
  642. data[0] = sutGpsInfo.year;
  643. data[1] = sutGpsInfo.month;
  644. data[2] = sutGpsInfo.day;
  645. data[3] = sutGpsInfo.hour;
  646. data[4] = sutGpsInfo.minu;
  647. data[5] = sutGpsInfo.sec;
  648. data[6] = sutGpsInfo.longitue>>24;
  649. data[7] = sutGpsInfo.longitue>>16;
  650. data[8] = sutGpsInfo.longitue>>8;
  651. data[9] = sutGpsInfo.longitue;
  652. data[10] = sutGpsInfo.latitue>>24;
  653. data[11] = sutGpsInfo.latitue>>16;
  654. data[12] = sutGpsInfo.latitue>>8;
  655. data[13] = sutGpsInfo.latitue;
  656. data[14] = sutGpsInfo.speed>>8;
  657. data[15] = sutGpsInfo.speed;
  658. data[16] = sutGpsInfo.aspect>>8;
  659. data[17] = sutGpsInfo.aspect;
  660. //st
  661. data[18] = 1;
  662. //空重载状态:表示范围:0-1采用压缩BCD编码.
  663. // 1 表示重载 0 表示空载
  664. data[19]= 0;
  665. //登退签状态:表示范围:0-1采用压缩BCD编码。
  666. // 1 表示登签 0 表示退签
  667. data[20] = 1;
  668. }
  669. */