123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718 |
- /**********************************************************************************
- * File Name: GpsProcess.c
- * Function Describe:device for Gps Process
- * Relate Module:
- * Explain:
- * Writer: ShiLiangWen
- * Date: 2015.1.26
- ***********************************************************************************/
- #define THIS_FILE_ID 11
- //-------------------------------------------------------------------------------------------
- #include "includes.h"
- SUT_GPS_SEND_DATA sutGpsSendData;
- /**********************************************************************************
- GpsSendHead
- ***********************************************************************************/
- void GpsServerConect(void)
- { //"AT+ZIPSEND=0,12\r"=41542B5A495053454E443D302C31320D
- //"AT+ZIPSENDU=0,12\r"=41542B5A495053454E44553D302C31320D
- //unsigned char Data[]={0x29,0x29,0xB1,0x00,0x07,0x59,0x69,0xB5,0xA1,0x00,0x92,0x0D}; //2929B100075969B5A100920D
- //ModemSendAT("AT+ZIPSEND=0,12\r"); //41542B5A495053454E443D302C31320D2929B100075969B5A100920D
- //ModemSendData(Data,sizeof(Data));
- int len;
- unsigned char buf[100];
- unsigned char temp=0;
- len=GpsPacket(buf,sutProductPara.PSN,XINGAN_PACKET_CLIENT_CMD_CONNECT,&temp,1);
- // if(WCDMA){
- // ModemSendTcpData(1,buf,len);//+ 1? WCDMA
- // }else{
- // ModemSendTcpData(0,buf,len);
- // }
- if(MODEM_TYPE==MODEM_TYPE_MW3650){
- MW3650ModemSendTcpData(1,buf,len);
- }else if(MODEM_TYPE==MODEM_TYPE_MC8332){
- MC8332ModemSendTcpData(0,buf,len);
- }
- }
- unsigned char GetCheckSum(unsigned char *pData,int len)
- {
- int i;
- unsigned char sum=0;
- for(i=0;i<len;i++){
- sum=sum^pData[i];
- }
- return sum;
- }
- /*************************************************************************************
- *
- **************************************************************************************/
- int GpsPacket(unsigned char *Buffer,unsigned long PSN,unsigned char CMD,unsigned char *pData,int DataLen)
- {
- unsigned char *pBuf=Buffer;
- int j,i=0;
- unsigned short Len=DataLen+6;
- pBuf[i++]=0x29;
- pBuf[i++]=0x29;
- pBuf[i++]=CMD;
- pBuf[i++]=(unsigned char)((Len>>8)&0xff);
- pBuf[i++]=(unsigned char)(Len&0xff);
- pBuf[i++]=(unsigned char)((PSN>>24)&0xff);
- pBuf[i++]=(unsigned char)((PSN>>16)&0xff);
- pBuf[i++]=(unsigned char)((PSN>>8)&0xff);
- pBuf[i++]=(unsigned char)(PSN&0xff);
- for(j=0;j<DataLen;j++){
- pBuf[i++]= pData[j];
- }
- pBuf[i]=GetCheckSum(pBuf,i);
- i++;
- pBuf[i++]=0x0D;
- return i;
- }
- /**********************************************************************************
- GpsSendPosition
- 发送位置数据
- Head(2) Cmd(1) Len(2) PSN(4) GpsData(34) Check(1) End(1)
- Cmd=0x80
- 总长度=2+1+2+40=45
- ***********************************************************************************/
- void GpsSendPosition(void)
- {
- int i;
- int len;
- char tmp[5];
- char buf[150];
- unsigned char GpsBuf[50];
- len=GpsPacket(GpsBuf,sutProductPara.PSN,0x80,(unsigned char *)&sutGpsSendData,sizeof(SUT_GPS_SEND_DATA));
- // if(WCDMA){
- //// sprintf(buf,"AT+ZIPSEND=0,%d\r",len);
- // sprintf(buf,"AT^IPSEND=1,%d\r",len);//+ 1? WCDMA
- // }else{
- // sprintf(buf,"AT+ZIPSEND=0,%d\r",len);
- // }
- if(MODEM_TYPE==MODEM_TYPE_MW3650){
- sprintf(buf,"AT^IPSEND=1,%d\r",len);
- }else if(MODEM_TYPE==MODEM_TYPE_MC8332){
- sprintf(buf,"AT+ZIPSEND=0,%d\r",len);
- }
- ModemSendAT(buf);
- ModemSendData(GpsBuf,len);
-
- strcpy(buf,"SendGpsD:");
- for(i=0;i<len;i++){
- sprintf(tmp,"%02x,",GpsBuf[i]);
- strcat(buf,tmp);
- }
- strcat(buf,"\r\n");
- SlwTrace(INF,buf);
- }
- /*******************************************************
- GPRMC信息,与,之间的子信息处理,存储到相应的结构体中元素中
- *******************************************************/
- void GPS_GPRMC_Handle(unsigned char *ch,unsigned char ch1)
- {
- unsigned char x,y;
- // send_byte('d');
- switch(ch1)
- {
- case 0: //时间
- for(x=0,y=0;x<8;x++)
- {
- if(x==2||x==5){ sutGpsInfo.Time[x]=0x3a;}
- else sutGpsInfo.Time[x]=ch[y++];
- }
- // send_byte(time[7]);
- break;
- case 1: //状态
- sutGpsInfo.Status=ch[0];
- break;
- case 2: //纬度
- for(x=10,y=0;x<17;x++)
- {
- if(x==12||x==15) {}
- else sutGpsInfo.Location[x]=ch[y++];
- }
- break;
- case 3: //南北纬
- sutGpsInfo.Location[9]=ch[0];
- break;
- case 4: //经度
- for(x=1,y=0;x<8;x++){
- if(x==4||x==7){}
- else sutGpsInfo.Location[x]=ch[y++];
- }
- break;
- case 5: //东西经
- sutGpsInfo.Location[0]=ch[0];
- break;
- case 6: //航速
- for(x=0;x<6;x++){
- sutGpsInfo.Speed[x+1]=ch[x];
- }
- sutGpsInfo.Speed[6]=0x20;
- sutGpsInfo.Speed[7]=0x20;
- break;
- case 7: //信息自己定义
- break;
- case 8: //信息自己定义
- break;
- case 9: //信息自己定义
- break;
- case 10: //信息自己定义
- break;
- case 11: //信息自己定义
- break;
- default:break;
- }
- }
- /*******************************************************
- 处理GPRMC信息
- *******************************************************/
- void GPS_GPRMC_Alysis(char *RMC_Data)
- {
- unsigned char i,j,k;
- unsigned char count;
- unsigned char temp[10];
- //send_byte('a');
- for(i=0;i<strlen(RMC_Data);)
- {
- switch(RMC_Data[i])
- {
- case '$':
- j=i++; //标记$的起始位置
- while(RMC_Data[i]!=',') //RMC_Data[i]==','时结束循环。
- {i++;}
- // uart1_sendbytes(GPRMC[RMC_Count].RMC_ID);
- break;
- case ',':
- j=i++; //标记,的起始位置
- while((RMC_Data[i]!=',')&&(RMC_Data[i]!='*')) //RMC_Data[i]==','或者=='*'时结束循环。
- {i++;}
- if(j+1!=i)
- {
-
- for(j=j+1,k=0;j<i;j++)
- {
- temp[k++]=RMC_Data[j];
- }
- temp[k]='\0';
- // send_byte(temp[0]);
- }
- else temp[0]='\0';
- // send_byte('c');
- GPS_GPRMC_Handle(temp,count++);
- break;
- case '*':
- i=strlen(RMC_Data); //处理完成,软件结束。
- break;
- default:break;
-
- }
- }
- // send_byte('e');
- }
- void GpsDataInit(void)
- {
- unsigned char *p;
- p=(unsigned char *)&sutGpsSendData;
- memset(p, 0, sizeof(SUT_GPS_SEND_DATA));
- p=(unsigned char *)&sutGpsInfo;
- memset(p, 0, sizeof(SUT_GPS_INF));
-
- switch(sutProductPara.m_GPS_SendTime)
- {
- case 0:case 10:case 15:case 30:case 60:
- break;
- default:
- sutProductPara.m_GPS_SendTime = 10;
- SaveProductParaToFlash();
- break;
- }
- sutGpsInfo.GPSSendTime = sutProductPara.m_GPS_SendTime;
- sutGpsInfo.SendTime = sutProductPara.m_GPS_SendTime;
- }
- /*************************************************************************
- *检查GPS 服务器发过来的数据包是否正确
- 非法 返回0
- 合法 返回命令码
- **************************************************************************/
- unsigned char GpsServerCheckPack(unsigned char *data,unsigned short DataLen)
- {
- int i=0;
- unsigned char cmd;
- unsigned short len;
- unsigned long PSN;
- //判断数据包的包头是否正确
- if(data[0]!=GPS_PACK_HEAD1)return 0;
- if(data[1]!=GPS_PACK_HEAD2)return 0;
- //判断数据包的校验是否正确
- if(data[DataLen-2] != GetCheckSum(data,DataLen-2))
- {
- return 0;
- }
- //判断数据包的结尾是否正确
- if(data[DataLen-1] != GPS_PACK_END)
- {
- return 0;
- }
- //获取数据包的长度 并判断长度是否正确
- len=(unsigned short)data[3]*256+data[4];
- if(DataLen!=(len+5))return 0;
- // //判断终端编号是否正确
- // PSN=(unsigned long)data[5]<<24;
- // PSN+=(unsigned long)data[6]<<16;
- // PSN+=(unsigned long)data[7]<<8;
- // PSN+=(unsigned long)data[8];
- // if(PSN!=sutNetPara.PSN) return 0;
- //解析当前命令
- cmd = data[2];
- sutGpsInfo.HostCmd = cmd;
- return cmd;
- }
- /**************************************************************************************************
- *
- ***************************************************************************************************/
- uint32_t Process_XinganCenterGetPos_rsp(unsigned char* buf, unsigned short len)
- {
- unsigned char SendBuf[100];
- unsigned short PacketLen;
- MakeGpsSendData();
- PacketLen=GpsPacket(SendBuf,sutProductPara.PSN,XINGAN_PACKET_CENTER_CMD_GET_POS_RSP,(unsigned char *)&sutGpsSendData,sizeof(SUT_GPS_SEND_DATA));
- // if(WCDMA){
- // ModemSendTcpData(1,SendBuf,PacketLen);//+ 1? WCDMA
- // }else{
- // ModemSendTcpData(0,SendBuf,PacketLen);
- // }
- if(MODEM_TYPE==MODEM_TYPE_MW3650){
- MW3650ModemSendTcpData(1,SendBuf,PacketLen);
- }else if(MODEM_TYPE==MODEM_TYPE_MC8332){
- MC8332ModemSendTcpData(0,SendBuf,PacketLen);
- }
- return 0;
- }
- uint32_t Process_XinganClient_rsp(char* buf, unsigned short len)
- {
- if(!sutGpsInfo.isServerLogin){
- sutGpsInfo.isServerLogin=1;
- SlwTrace(INF,"[Gps Logined]\r\n");
- }
- return 0;
- }
- /**************************************************************************************************
- *
- ***************************************************************************************************/
- void GpsTimingSendPos(void)
- {
- unsigned char SendBuf[100];
- unsigned short PacketLen;
- //if(sutGpsInfo.isGpsWork==0)return;
- MakeGpsSendData();
- PacketLen=GpsPacket(SendBuf,sutProductPara.PSN,XINGAN_PACKET_CLIENT_SEND_POS_DATA,(unsigned char *)&sutGpsSendData,sizeof(SUT_GPS_SEND_DATA));
- // if(WCDMA){
- // ModemSendTcpData(1,SendBuf,PacketLen);//+ 1? WCDMA
- // }else{
- // ModemSendTcpData(0,SendBuf,PacketLen);
- // }
- if(MODEM_TYPE==MODEM_TYPE_MW3650){
- MW3650ModemSendTcpData(1,SendBuf,PacketLen);
- }else if(MODEM_TYPE==MODEM_TYPE_MC8332){
- MC8332ModemSendTcpData(0,SendBuf,PacketLen);
- }
- return ;
- }
- /***********************************************************************************
- *服务器设置主动上报时间
- *数据格式
- HEAD1 HEAD2 CMD LEN1 LEN2 PSN1 PSN2 PSN3 PSN4 X1 X2 CHECK END
- 29 29 34 00 08 PSN[4] X1 X2 CHECK 0D
- time=X1*256+X2
- ***********************************************************************************/
- uint32_t Process_XinganCenterGetPosTimerout(char* buf, uint32_t len)
- {
- char SendBuf[100];
- unsigned short t;
- unsigned short PacketLen;
- //跳过终端序列号4 bytes
-
- //获取时间
- sutGpsInfo.SendTime =((unsigned short)buf[9]&0xff<<8) + (unsigned short)buf[10]&0xff ;
- sprintf(SendBuf,"[GpsTime=%d]\r\n",sutGpsInfo.SendTime);
- SlwTrace(INF,SendBuf);
- //ol_start_AppTimer( XINGAN_SENDBACK_TIMER, g_xingan_info.timeout * KAL_TICKS_1_SEC);
- MakeGpsSendData();
- PacketLen=GpsPacket(SendBuf,sutProductPara.PSN,XINGAN_PACKET_CENTER_CMD_COMMON_RSP,(unsigned char *)&sutGpsSendData,sizeof(SUT_GPS_SEND_DATA));
- // if(WCDMA){
- // ModemSendTcpData(1,SendBuf,PacketLen);//+ 1? WCDMA
- // }else{
- // ModemSendTcpData(0,SendBuf,PacketLen);
- // }
- if(MODEM_TYPE==MODEM_TYPE_MW3650){
- MW3650ModemSendTcpData(1,SendBuf,PacketLen);
- }else if(MODEM_TYPE==MODEM_TYPE_MC8332){
- MC8332ModemSendTcpData(0,SendBuf,PacketLen);
- }
- return len;
- }
- /******************************************************************************
- *
- *******************************************************************************/
- XinganCmd_struct XinganCmd_info[] =
- {
- {XINGAN_PACKET_CENTER_CMD_GET_POS, Process_XinganCenterGetPos_rsp},
- // {XINGAN_PACKET_CENTER_CMD_GET_STAT, Process_XinganCenterGetStat_rsp},
- // {XINGAN_PACKET_CENTER_CMD_RESET, Process_XinganCenterReset_rsp},
- // {XINGAN_PACKET_CENTER_CMD_DEFAULT_SET, Process_XinganCenterDefaultSet_rsp},
- {XINGAN_PACKET_CENTER_CMD_GET_POS_TIMEOUT, Process_XinganCenterGetPosTimerout},
- // {XINGAN_PACKET_CENTER_CMD_GET_POS_LENOUT, Process_XinganCenterGetPosLenout},
- // {XINGAN_PACKET_CENTER_CMD_CLOSE_WARNING, Process_XinganCenterCloseWarning_rsp},
- // {XINGAN_PACKET_CENTER_CMD_OPEN_OIL_WAY, Process_XinganCenterOpenOilWay_rsp},
- // {XINGAN_PACKET_CENTER_CMD_CLOSE_OIL_WAY, Process_XinganCenterCloseOilWay_rsp},
- // {XINGAN_PACKET_CENTER_CMD_GET_VER, Process_XinganCenterGetVer_rsp},
- // {XINGAN_PACKET_CENTER_CMD_DIAL_CALL, Process_XinganCenterDialCall_rsp} ,
- // {XINGAN_PACKET_CENTER_CMD_HIGH_SPEED_WARNING, Process_XinganCenterHighSpeedWarning_rsp},
- // {XINGAN_PACKET_CENTER_CMD_STATISTICS_MILE, Process_XinganCenterStatisticsMile_rsp},
- // {XINGAN_PACKET_CENTER_CMD_UDP_IPPORT, Process_XinganCenterIPport_rsp},
- // {XINGAN_PACKET_CENTER_CMD_APN, Process_XinganCenterApn_rsp},
- //
- {XINGAN_PACKET_CLIENT_CMD_COMMON_RSP, Process_XinganClient_rsp},
- //
- // {XINGAN_PACKET_CLIENT_CMD_CONNECT, Process_XinganClientConnectReq},
- // {XINGAN_PACKET_CLIENT_SEND_POS_DATA, Process_XinganClientSendPosData},
- // {XINGAN_PACKET_CLIENT_CMD_SEND_WARNING_DATA, Process_XinganClientSendWarnData},
-
- };
- Xingan_process_packet GetXinganProcessFun(uint32_t Cmd)
- {
- uint32_t j;
- for(j=0;j<sizeof(XinganCmd_info)/sizeof(XinganCmd_struct);j++)
- {
- if(Cmd == XinganCmd_info[j].cmd)
- {
- return XinganCmd_info[j].process_packet;
- }
- }
- return NULL;
- }
- /***************************************************************
- 处理GPS服务器发过来的信息
- 返回:
- 无效消息 不处理 返回0
- 否则返回命令码
- ****************************************************************/
- unsigned char GpsServerProcess(unsigned char *data, unsigned short DataLen)
- {
- unsigned char cmd;
- Xingan_process_packet ProcessFun;
- cmd=GpsServerCheckPack(data,DataLen);
- if(!cmd)return 0;
- ProcessFun = GetXinganProcessFun(cmd);
- if(ProcessFun !=NULL)
- {
- ProcessFun(data, DataLen);
- }
- return cmd;
- }
- //#define GPS_DEBUG_GPS_SEND_DATA //////////////////////////////打开它会锁死定位
- /***************************************************************************
- *MakeGpsSendData
- 根据sutGpsInfo生成sutGpsSendData
- ****************************************************************************/
- void MakeGpsSendData(void)
- {
- #ifdef GPS_DEBUG_GPS_SEND_DATA
- int i;
- const unsigned char acucTemp[]={
- 0x15,0x07,0x25,0x15,0x41,0x18,//yymmddhhmmss
- 0x02,0x23,0x75,0x49, //wwww 纬度
- 0x11,0x40,0x13,0x22, //jjjj 经度
- 0x00,0x07,0x01,0x28, //ssff 速度方向
- 0xf8,//st 状态
- 0x01,0xE2,0x40,//里程数 1E240=123456米
- 0x00,0x00,0x7f,//车辆状态 St1~St4
- 0x00,0x00,0x05,0x00,0x00,0x00,0x01,0x00,//V1~V8
- };
- unsigned char *p=(unsigned char *)&sutGpsSendData;
- for(i=0;i<sizeof(acucTemp);i++){
- p[i]=acucTemp[i];
- }
- #else
- unsigned char *data=(unsigned char *)&sutGpsSendData;
- memset(data, 0, sizeof(SUT_GPS_SEND_DATA));
- data[0] = sutGpsInfo.year;
- data[1] = sutGpsInfo.month;
- data[2] = sutGpsInfo.day;
- data[3] = sutGpsInfo.hour;
- data[4] = sutGpsInfo.minu;
- data[5] = sutGpsInfo.sec;
-
- data[6] = (sutGpsInfo.latitue>>24)&0xFF;
- data[7] = (sutGpsInfo.latitue>>16)&0xFF;
- data[8] = (sutGpsInfo.latitue>>8)&0xFF;
- data[9] = (sutGpsInfo.latitue)&0xFF;
-
- data[10] = (sutGpsInfo.longitue>>24)&0xFF;
- data[11] = (sutGpsInfo.longitue>>16)&0xFF;
- data[12] = (sutGpsInfo.longitue>>8)&0xFF;
- data[13] = (sutGpsInfo.longitue)&0xFF;
-
- data[14] = (sutGpsInfo.speed>>8)&0xFF;
- data[15] = (sutGpsInfo.speed)&0xFF;
-
- data[16] = (sutGpsInfo.aspect>>8)&0xFF;
- data[17] = (sutGpsInfo.aspect)&0xFF;
-
- //st;
- if(sutGpsInfo.isGpsWork==1 && sutGpsInfo.isGpsValid == 1){
- data[18] = 0x80;
- }
- /*
- if(sutGpsInfo.isGpsValid == 1 )
- {
- data[18] |= (0x01<<7);
- }
-
- if(sutGpsInfo.isGpsValid == 0)
- {
- data[18] |= (0x01<<6);
- data[18] |= (0x01<<5);
- }
- else if(sutGpsInfo.isGpsValid == 0)//:GPS天线短路
- {
- data[18] |= (0x01<<6);
- }
- else if(sutGpsInfo.isGpsValid == 0)//:GPS天线开路;
- {
- data[18] |= (0x01<<5);
- }
- else if(sutGpsInfo.isGpsValid == 0) //0x03:GPS模块故障
- {
-
- }
- */
- // if(sutGpsInfo.MainPowerStat ==0 )//主电源正常
- // {
- // data[18] |= (0x01<<4);
- // data[18] |= (0x01<<3);
- // }
- // else if(sutGpsInfo.MainPowerStat == 1)//主电源掉电
- // {
- // data[18] |= (0x01<<4);
- // }
- // else if(sutGpsInfo.MainPowerStat == 2 || g_xingan_info.MainPowerStat ==3)//主电源过高或过低
- // {
- // data[18] |= (0x01<<3);
- // }
-
- //里程数
- data[19] = (sutGpsInfo.StatisticsMile>>16)&0xFF;
- data[20] = (sutGpsInfo.StatisticsMile>>8)&0xFF;
- data[21] = (sutGpsInfo.StatisticsMile)&0xFF;
-
- //St1:
- // if(GetAccStat() == FALSE)//ACC关
- // {
- // data[22] |= (0x01<<7);
- // }
- // if(GetHighSensor1Stat() == FALSE)//自定义1路高传感器状态为低
- // {
- // data[22] |= (0x01<<6);
- // }
- // if(GetHighSensor2Stat() == FALSE)//自定义2路高传感器状态为低
- // {
- // data[22] |= (0x01<<5);
- // }
- // if(GetLowSensor1Stat() == TRUE)//自定义1路低传感器状态为高
- // {
- // data[22] |= (0x01<<4);
- // }
- // if(GetLowSensor2Stat()== TRUE)//自定义2路低传感器状态为高
- // {
- // data[22] |= (0x01<<3);
- // }
- //
- // if(GetOilWayStat()== TRUE)//油路正常
- // {
- // data[22] |= (0x01<<2);
- // }
- //
- // if(GetLoginStat() == FALSE)//没有登签
- // {
- // data[22] |= (0x01<<1);
- // }
- //
- // if(GetWarningStat() == FALSE)//未设防
- // {
- // data[22] |= (0x01);
- // }
-
- //st2:
- // if(GetRobWarningStat()== FALSE)//不为劫警报警
- // {
- // data[23] |= (0x01<<7);
- // }
- //
- // if(GetHighSpeedWarningStat()== FALSE)//不为超速报警
- // {
- // data[23] |= (0x01<<6);
- // }
- // if(GetStopTimeoutStat()== FALSE)//不为停车超长报警
- // {
- // data[23] |= (0x01<<5);
- // }
- // if(GooutOfRegion()== FALSE)//不为驶出区域报警
- // {
- // data[23] |= (0x01<<4);
- // }
- // if(ComeintoRegion()==FALSE)//不为驶入区域报警
- // {
- // data[23] |= (0x01<<3);
- // }
- //
- // if(PasswordIsOK()== TRUE)//不为看车密码错误报警
- // {
- // data[23] |= (0x01<<2);
- // }
- //
- // if(GprsIsLogin() == FALSE)//不为GPRS已上线
- // {
- // data[23] |= (0x01<<1);
- // }
- //
- // if(PppIsOK() == FALSE)//不为终端拨号成功
- // {
- // data[23] |= (0x01);
- // }
-
- //st3:
- // if(GprsIsLogin() == FALSE)//GPRS未注册
- // {
- // data[24] |= (0x01<<7);
- // }else{
- data[24] &= ~(0x01<<7);
- // }
- // if(CenterNeedSendCmd21() == TRUE)//中心应下发21指令
- // {
- data[24] |= (0x01<<6);
- // }
- // if(g_xingan_info.SendMode == XINGAN_PACKET_SEND_TCP)//TCP通讯方式
- // {
- data[24] |= (0x01<<5);
- // }
- //:CSQ信号状态0-31
- data[24] += (char)g_iCSQ;
-
- //st4
- // if(IsHandleOK()== TRUE)//手柄接入
- // {
- // data[25] |= (0x01<<7);
- // }
- // if(IsLcdOK() == TRUE)//LCD显示屏接入
- // {
- // data[25] |= (0x01<<6);
- // }
- // if(IsImageCollectorOK()== TRUE)//图像采集器接入
- // {
- // data[25] |= (0x01<<5);
- // }
- // if(IsFareMeterOK()== TRUE)//计价器接入
- // {
- // data[25] |= (0x01<<4);
- // }
- // if(IsVoiceDialerOK()==TRUE)//语音波号器接入
- // {
- // data[25] |= (0x01<<3);
- // }
- // if(IsForbiddenDialCall()==TRUE)//禁止打出
- // {
- // data[25] |= (0x01<<2);
- // }
- // if(IsForbiddenReceiveCall()==TRUE)//禁止打入
- // {
- // data[25] |= (0x01<<1);
- // }
- // if(IsForbiddenAllCalls()==TRUE)//禁止通话
- // {
- // data[25] |= (0x01);
- // }
-
- //v1v2v3v4:终端设置状态
- //V1V2:定时发送时间
- data[26] = (sutGpsInfo.SendTime>>8)&0xFF;
- data[27] = (sutGpsInfo.SendTime)&0xFF;
-
- //V3: 停车设置时间
- //data[28]= sutGpsInfo.StopTimeout&0xFF;
- //V4: 超速设置时间
- // data[29]= sutGpsInfo.HighSpeed;
- //V5; 电子围栏设置个数
- // data[30]= sutGpsInfo.ElectronicFenceNum;
-
- //V6: 登签
- if(sutGpsInfo.isServerLogin)data[31] = 1;
- else data[31] = 0;
- //: 定时发送图片的时间
- data[32] = 0;//
- //: 中心下发的主命令
- data[33]= sutGpsInfo.HostCmd;
- #endif
- }
- /*
- void MakeGpsData(void)
- {
- unsigned char *data=(unsigned char *)&sutGpsSendData;
- if(!sutGpsInfo.isGpsValid)return;
- data[0] = sutGpsInfo.year;
- data[1] = sutGpsInfo.month;
- data[2] = sutGpsInfo.day;
- data[3] = sutGpsInfo.hour;
- data[4] = sutGpsInfo.minu;
- data[5] = sutGpsInfo.sec;
-
- data[6] = sutGpsInfo.longitue>>24;
- data[7] = sutGpsInfo.longitue>>16;
- data[8] = sutGpsInfo.longitue>>8;
- data[9] = sutGpsInfo.longitue;
-
- data[10] = sutGpsInfo.latitue>>24;
- data[11] = sutGpsInfo.latitue>>16;
- data[12] = sutGpsInfo.latitue>>8;
- data[13] = sutGpsInfo.latitue;
-
- data[14] = sutGpsInfo.speed>>8;
- data[15] = sutGpsInfo.speed;
-
- data[16] = sutGpsInfo.aspect>>8;
- data[17] = sutGpsInfo.aspect;
-
- //st
- data[18] = 1;
-
- //空重载状态:表示范围:0-1采用压缩BCD编码.
- // 1 表示重载 0 表示空载
- data[19]= 0;
-
- //登退签状态:表示范围:0-1采用压缩BCD编码。
- // 1 表示登签 0 表示退签
- data[20] = 1;
- }
- */
|