void Read_USART(void) { memcpy(received_buff, usart_buffer, MAX_STRLEN); p = (char *)received_buff; pch = strchr(p, '$'); i = pch-p+1; // megkeressük az elsö csillagot pch = strchr(pch+1, '$'); NMEA_Parse(received_buff, MAX_STRLEN); }
static void gps_update_info(struct gps_desc *gps, char *info) { char *ptr; short i = 0; short read_leng = 0; short total_leng = 0; memset(info, '\n', INFO_SIZE); info[INFO_SIZE-1] = 0x0; if(sockfd != C_INVALID_SOCKET) { memset(nmea_buf, 0, NMEA_SIZE); //do //{ LOGD(TAG"read from sockfd 1\n"); read_leng = read(sockfd, &nmea_buf[total_leng], (NMEA_SIZE - total_leng)); total_leng += read_leng; LOGD(TAG"read_leng=%d, total_leng=%d\n", read_leng, total_leng); //}while((read_leng > 0) /*|| ((total_leng > 0) && (nmea_buf[total_leng-1] != '\n'))*/); if (read_leng <= 0) { LOGD(TAG"ERROR reading from socket\n"); sprintf(gps->info, "%s\n", uistr_info_gps_error); gps->exit_thd = true; } else if(total_leng > 0) { NMEA_Parse((char*)&nmea_buf[0]); ptr = info; if(((g_gpsInfo.FixType != 0) && (ttff != 0)/*avoid prev second's NMEA*/) || (fixed == 1)) // 2D or 3D fixed { ptr += sprintf(ptr, "%s: %d\n", uistr_info_gps_fixed, ttff); fixed = 1; //for auto test LOGD(TAG"Fix success"); // ttff_check_res = 1; } else if((g_gpsInfo.FixType != 0) && (ttff == 0)) //skip prev second's NMEA, clear data { ptr += sprintf(ptr, "%s: %d\n", uistr_info_gps_ttff, ttff++); memset(&g_gpsInfo, 0, sizeof(g_gpsInfo)); memset(g_svInfo, 0, (sizeof(SVInfo)*NUM_CH)); memset(g_chInfo, 0, (sizeof(ChInfo)*PSEUDO_CH)); } else // no fix { ptr += sprintf(ptr, "%s: %d\n", uistr_info_gps_ttff, ttff++); } for(i = 0; i < g_gpsInfo.SV_cnt; i++) { ptr += sprintf(ptr, "%s[%d] : %d\n", uistr_info_gps_svid, g_svInfo[i].SVid, g_svInfo[i].SNR); ttff_check_res = 1; } } } return; }