4216a4217,4227 > // gpsd response > char json_tpv_object[1024]; > // protocol markers > char LAT_FIELD[]= "lat\":"; > char LON_FIELD[]= "lon\":"; > char ALT_FIELD[]= "alt\":"; > char VEL_FIELD[]="speed\":"; > char COURSE_FIELD[]= "track\":"; > // tmp reference > char* jason_offset; > 4219c4230 < char line[256], *p; --- > char line[256]; 4221d4231 < int ret; 4249a4260 > // New gpsd protocol POLL command: 4251,4252c4262,4264 < snprintf( line, sizeof( line ) - 1, "PVTAD\r\n" ); < if( send( gpsd_sock, line, 7, 0 ) != 7 ) --- > snprintf( line, sizeof( line ) - 1, "?POLL;\r\n" ); > if( send( gpsd_sock, line, 8, 0 ) != 8 ) > { 4254c4266 < --- > } 4256c4268 < return; --- > return; //? 4258,4259c4270,4272 < memset( line, 0, sizeof( line ) ); < if( recv( gpsd_sock, line, sizeof( line ) - 1, 0 ) <= 0 ) --- > // New gpsd protocol response (json object) > memset( json_tpv_object, 0, sizeof( json_tpv_object ) ); > if( recv( gpsd_sock, json_tpv_object, sizeof( json_tpv_object ) - 1, 0 ) <= 0 ) 4261d4273 < 4265,4282c4277,4300 < if( memcmp( line, "GPSD,P=", 7 ) != 0 ) < continue; < < /* make sure the coordinates are present */ < < if( line[7] == '?' ) < continue; < < ret = sscanf( line + 7, "%f %f", &G.gps_loc[0], &G.gps_loc[1] ); < < if( ( p = strstr( line, "V=" ) ) == NULL ) continue; < ret = sscanf( p + 2, "%f", &G.gps_loc[2] ); /* speed */ < < if( ( p = strstr( line, "T=" ) ) == NULL ) continue; < ret = sscanf( p + 2, "%f", &G.gps_loc[3] ); /* heading */ < < if( ( p = strstr( line, "A=" ) ) == NULL ) continue; < ret = sscanf( p + 2, "%f", &G.gps_loc[4] ); /* altitude */ --- > // latitude > jason_offset= strstr(json_tpv_object,LAT_FIELD); > if (jason_offset != 0) > sscanf(jason_offset+sizeof(LAT_FIELD)-1,"%f,%*s",&G.gps_loc[0]); > > // longitude > jason_offset= strstr(json_tpv_object,LON_FIELD); > if (jason_offset != 0) > sscanf(jason_offset+sizeof(LON_FIELD)-1,"%f,%*s",&G.gps_loc[1]); > > // altitude > jason_offset= strstr(json_tpv_object,ALT_FIELD); > if (jason_offset != 0) > sscanf(jason_offset+sizeof(ALT_FIELD)-1,"%f,%*s",&G.gps_loc[2]); > > // velocity > jason_offset= strstr(json_tpv_object,VEL_FIELD); > if (jason_offset != 0) > sscanf(jason_offset+sizeof(VEL_FIELD)-1,"%f,%*s",&G.gps_loc[3]); > > // course > jason_offset= strstr(json_tpv_object,COURSE_FIELD); > if (jason_offset != 0) > sscanf(jason_offset+sizeof(COURSE_FIELD)-1,"%f,%*s",&G.gps_loc[4]); 4285c4303 < fputs( line, G.f_gps ); --- > fputs( json_tpv_object, G.f_gps );