| | |
| | | #include "board.h" |
| | | //#include "Spi.h" |
| | | //#include "radio.h" |
| | | |
| | | #include "DBG.h" |
| | | |
| | | |
| | | //#define EUART_RX_BUF_SIZE 100 |
| | |
| | | |
| | | } |
| | | double d_value; |
| | | uint8_t shell_receive_state; |
| | | //static HIDO_UINT8 l_u8GPSBuff[512]; |
| | | //static HIDO_UINT32 l_u8GPSLen = 0; |
| | | //static HIDO_UINT32 l_u8GPSRecvTick = 0; |
| | | void UsartParseDataHandler(uint8_t data) |
| | | { |
| | | if(state5V_prase_flag&&!g_com_map[MODBUS_MODE]) |
| | |
| | | uint16_t checksum = 0; |
| | | static uint8_t pack_datalen = 0,pack_length = 0,pack_index = 0,pack_msgtype = 0,pack_cmd = CMD_READ; |
| | | static uint8_t index = 0; |
| | | |
| | | //uint8_t shell_receive_state; |
| | | |
| | | |
| | | |
| | |
| | | } else if ((usart_receive_state == UsartReceiveWaitMsgType) && (data == 0x3)) { |
| | | usart_receive_state = UsartReceiveWaitLength; |
| | | pack_msgtype = data; |
| | | } else if ((shell_receive_state == 0) && (data == 0x03)) { |
| | | shell_receive_state = 1; |
| | | uart_send(UART_ID1, data,1, NULL); |
| | | } else if ((shell_receive_state == 1) && (data == 0x03)) { |
| | | shell_receive_state = 2; |
| | | uart_send(UART_ID1, data,1, NULL); |
| | | } else if ((shell_receive_state == 2) && (data == 0x03)) { |
| | | DBG_SetMode(DBG_MODE_SHELL); |
| | | uart_send(UART_ID1, data,1, NULL); |
| | | shell_receive_state=0; |
| | | } |
| | | else { |
| | | usart_receive_state = UsartReceiveWaitHead0; |
| | |
| | | } |
| | | } else if(gps_prase_flag) |
| | | { |
| | | static uint8_t index = 0; |
| | | // static uint8_t index = 0; |
| | | //GPS解析数据 |
| | | // static ST_BLERecv BLE_recvive; |
| | | GGA_DataStruct jdrecv,wdrecv,Posstate; |
| | | // GGA_DataStruct jdrecv,wdrecv,Posstate; |
| | | GPS_RecvFsm(data); |
| | | // l_u8GPSBuff[l_u8GPSLen++] = data; |
| | | // if(l_u8GPSLen >= sizeof(l_u8GPSBuff)) |
| | | // { |
| | | // NTRIPApp_ReportGGA(l_u8GPSBuff, l_u8GPSLen); |
| | | // l_u8GPSLen = 0; |
| | | // } |
| | | |
| | | //接收数据开始分析 |
| | | mUsart2ReceivePack[index] = data; //char数组传进来参数data |
| | | mUsart2ReceivePack_before = mUsart2ReceivePack_now; |
| | | mUsart2ReceivePack_now=data; |
| | | index++; |
| | | if( mUsart2ReceivePack_before == 0x0D && mUsart2ReceivePack_now==0x0A )//接收数据到“0x0D 0x0A”结束 |
| | | { |
| | | //解析该条GPS报文 |
| | | |
| | | analysis_num=sscanf((char*)mUsart2ReceivePack,"$%[^,],%*[^,],%[^,],%*[^,],%[^,],%*[^,],%[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*s",gps_header,wdrecv.m_pData,jdrecv.m_pData,Posstate.m_pData); |
| | | if(!memcmp(gps_header,"GNGGA",5)) |
| | | { |
| | | memcpy(GPS_GGAmessage,mUsart2ReceivePack,strlen(mUsart2ReceivePack)-2); |
| | | |
| | | wd=strtod(wdrecv.m_pData,NULL); |
| | | jd=strtod(jdrecv.m_pData,NULL); |
| | | if(wd!=0) |
| | | pos_state=atoi(Posstate.m_pData); |
| | | if(pos_state!=0) |
| | | { |
| | | pos_state=0;//防止多次进入 |
| | | } |
| | | |
| | | } |
| | | // if(!memcmp(gps_header,"GBGSV",5)) |
| | | // {memcpy(GPS_GSVmessage,mUsart2ReceivePack,strlen(mUsart2ReceivePack)-2); |
| | | // GPS_ParseGSV(GPS_GSVmessage,strlen(GPS_GSVmessage)); |
| | | // l_u8GPSRecvTick = HIDO_TimerGetTick(); |
| | | // //接收数据开始分析 |
| | | // mUsart2ReceivePack[index] = data; //char数组传进来参数data |
| | | // mUsart2ReceivePack_before = mUsart2ReceivePack_now; |
| | | // mUsart2ReceivePack_now=data; |
| | | // index++; |
| | | // if( mUsart2ReceivePack_before == 0x0D && mUsart2ReceivePack_now==0x0A )//接收数据到“0x0D 0x0A”结束 |
| | | // { |
| | | // //解析该条GPS报文 |
| | | // |
| | | // analysis_num=sscanf((char*)mUsart2ReceivePack,"$%[^,],%*[^,],%[^,],%*[^,],%[^,],%*[^,],%[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*s",gps_header,wdrecv.m_pData,jdrecv.m_pData,Posstate.m_pData); |
| | | // if(!memcmp(gps_header,"GNGGA",5)) |
| | | // { |
| | | // memcpy(GPS_GGAmessage,mUsart2ReceivePack,strlen(mUsart2ReceivePack)-2); |
| | | // |
| | | // wd=strtod(wdrecv.m_pData,NULL); |
| | | // jd=strtod(jdrecv.m_pData,NULL); |
| | | // if(wd!=0) |
| | | // pos_state=atoi(Posstate.m_pData); |
| | | // if(pos_state!=0) |
| | | // { |
| | | // pos_state=0;//防止多次进入 |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | memset(mUsart2ReceivePack,0,sizeof(mUsart2ReceivePack)); |
| | | memset(wdrecv.m_pData,0,sizeof(wdrecv.m_pData)); |
| | | memset(jdrecv.m_pData,0,sizeof(jdrecv.m_pData)); |
| | | memset(Posstate.m_pData,0,sizeof(Posstate.m_pData)); |
| | | index=0; |
| | | mUsart2ReceivePack_before=0; |
| | | mUsart2ReceivePack_now=0; |
| | | } |
| | | // } |
| | | //// if(!memcmp(gps_header,"GBGSV",5)) |
| | | //// {memcpy(GPS_GSVmessage,mUsart2ReceivePack,strlen(mUsart2ReceivePack)-2); |
| | | //// GPS_ParseGSV(GPS_GSVmessage,strlen(GPS_GSVmessage)); |
| | | //// |
| | | //// } |
| | | // |
| | | // memset(mUsart2ReceivePack,0,sizeof(mUsart2ReceivePack)); |
| | | // memset(wdrecv.m_pData,0,sizeof(wdrecv.m_pData)); |
| | | // memset(jdrecv.m_pData,0,sizeof(jdrecv.m_pData)); |
| | | // memset(Posstate.m_pData,0,sizeof(Posstate.m_pData)); |
| | | // index=0; |
| | | // mUsart2ReceivePack_before=0; |
| | | // mUsart2ReceivePack_now=0; |
| | | // } |
| | | } |
| | | } |
| | | |