/********************************************************************************** * File Name: TSGpsProcess.c * Function Describe:device for Gps Process for TS/T808 * Relate Module: * Explain: ²ÉÓÃTCP»òUDP¸ñʽ´«Êä * Writer: wuzhao * Date: 2015.12.14 *ÍâÉèÀàÐÍ£º0x01£¬ *ÃüÁîÀàÐÍ£º0x05 ***********************************************************************************/ #define THIS_FILE_ID 24 //------------------------------------------------------------------------------------------- #include "includes.h" SUT_GPS_SEND_DATA sutGpsSendData; //SUT_PRODUCT_PARA TSsutProductPara; REGISTRATION Regist; AVL_MSG_BODY_ATTRIB msgBodyAttrib; MSG_HEAD msghead; MSG_PACKET msgPacket; AUTH auth; SIM SimData; unsigned int a; unsigned int b; char GPSDataBuf[8]; char GPSDataBuf1[8]; //*p_buf -- *m_data size -- m_size /********************************************************************************** GpsSendHead ***********************************************************************************/ void TSGpsServerConect(void) { int len; unsigned char buf[100]; unsigned char temp[5]; SUTDS ds; SlwTrace(INF, "Device ACK",1); memcpy(temp, (unsigned char*)&sutFeed.feedliushuiID,2); ds.Data.usData=sutFeed.feedID; temp[2] = ds.Data.ucData.b2; temp[3] = ds.Data.ucData.b1; temp[4] = sutFeed.result; len=TSGpsPacket(buf,sutProductPara.PSN,TS_TERMINAL_UNIVERSAL_ANSWER,temp,sizeof(temp)); MC8332ModemSendTcpData(GPS_DATA_SOCKET,buf,len); } //´Ó³§É̱àºÅµ½Óû§Êý¾ÝÒÀ´ÎÀÛ¼ÓµÄÀۼӺͣ¬È¡ÀۼӵĵµÍ8λ×÷ΪУÑéÂë unsigned char TSGetCheckSum(unsigned char *pData,int len) { int i; unsigned char sum= pData[1]; //sum=0; for(i=1;i>8)&0xff; pBuf[i++]=ID&0xff; //ÏûÏ¢ÌåÊôÐÔ msgBodyAttrib.EncrypType=NO_ENCRYP;//NO_ENCRYP; msgBodyAttrib.msgBodyLength=(DataLen); pBuf[i++]=msgBodyAttrib.EncrypType; pBuf[i++]=msgBodyAttrib.msgBodyLength; for(j=0;j<6;j++){ pBuf[i++]=SimData.SIM[j]; } //ÏûÏ¢Á÷Ë®ºÅ pBuf[i++] = (liushiID>>8)&0xff; pBuf[i++] = liushiID&0xff; liushiID++; if(pData!=NULL) { //snum++; //ÏûÏ¢°ü·â×°Ïî //msgPacket.msgPacketID=0x30; //msgPacket.msgTotalCount=0x30; //pBuf[i++] = msgPacket.msgPacketID; //pBuf[i++] = msgPacket.msgTotalCount; //MSnum++; //°ü·â×°Ïî 4 for(j=0;j>4)&0x0F)*10 + (bcd[i]&0x0F); dec += tmp * power(100, length-1-i); } return dec; } /******************************************************** 10½øÖÆתBCD ********************************************************/ int DectoBCD(int Dec, unsigned char *Bcd, int length) { int i; int temp; for(i=length-1; i>=0; i--) { temp = Dec%100; Bcd[i] = ((temp/10)<<4) + ((temp%10) & 0x0F); Dec /= 100; } return 0; } //#define GPS_DEBUG_GPS_SEND_DATA /*************************************************************************** *MakeGpsSendData ¸ù¾ÝsutGpsInfoÉú³ÉsutGpsSendData ****************************************************************************/ void TSMakeGpsSendData(void)//5´¦ { char sv[17]; char data[3]; char buf[10]; int buf1[3]; int j,temp,num; char *pTemp; char WWWW[5]; static int Table[4]={0}; static int Table1[4]={0}; sutGpsSendData.Time[0] = sutGpsInfo.year; sutGpsSendData.Time[1] = sutGpsInfo.month; sutGpsSendData.Time[2] = sutGpsInfo.day; sutGpsSendData.Time[3] = sutGpsInfo.hour; sutGpsSendData.Time[4] = sutGpsInfo.minu; sutGpsSendData.Time[5] = sutGpsInfo.sec; sutGpsSendData.St=0x00; sutGpsSendData.status=0; if(sutGpsInfo.isGpsValid) { sutGpsSendData.status |=(1<<24);//b0 1 acc sutGpsSendData.status |=(1<<25);//b1 1 ¶¨Î» if(sutGpsInfo.NSFlag=='S') sutGpsSendData.status |=(1<<26);//b2 1 ÄÏγ if(sutGpsInfo.EWFlag=='W') sutGpsSendData.status |=(1<<27);//b3 1 Î÷¾­ sutGpsSendData.status |=(1<<28);//b4 1 ÔËÓª } sutGpsSendData.Mileag=((sutGpsInfo.StatisticsMile>>8)&0xFF)|(((sutGpsInfo.StatisticsMile)&0xFF)<<8); sutGpsSendData.SSFF=((sutGpsInfo.speed>>8)&0xFF)|(((sutGpsInfo.speed)&0xFF)<<8); sutGpsSendData.Acpect=sutGpsInfo.aspect; GetCoordinates(1); sutGpsSendData.WWWW[0] = sutGpsInfo.testWD>>24; sutGpsSendData.WWWW[1] = sutGpsInfo.testWD>>16; sutGpsSendData.WWWW[2] = sutGpsInfo.testWD>>8; sutGpsSendData.WWWW[3] = sutGpsInfo.testWD; sutGpsSendData.JJJJ[0] = sutGpsInfo.testJD>>24; sutGpsSendData.JJJJ[1] = sutGpsInfo.testJD>>16; sutGpsSendData.JJJJ[2] = sutGpsInfo.testJD>>8; sutGpsSendData.JJJJ[3] = sutGpsInfo.testJD; } void AscStrTurnHexStr(char *AscStr, char *HexStr) { char *pAscStr=AscStr; int i=4; unsigned char d,h,l; while(i){ d=(unsigned char)*pAscStr++; l=d&0x0f; h=d>>4; *HexStr++=AscToHex(h); *HexStr++=AscToHex(l); i--; } *HexStr=0; }