mirror of
https://github.com/csete/gpredict
synced 2026-08-13 17:39:46 -04:00
for libgps 3.22
This commit is contained in:
parent
d86ffc1d54
commit
533cbcef93
1 changed files with 82 additions and 0 deletions
|
|
@ -567,6 +567,60 @@ gboolean qth_data_update(qth_t * qth, gdouble t)
|
|||
}
|
||||
#endif
|
||||
break;
|
||||
case 11:
|
||||
#if GPSD_API_MAJOR_VERSION==11 /* for libgps 3.22 */
|
||||
while (gps_waiting(qth->gps_data, 0) == 1)
|
||||
{
|
||||
/* see comment from above */
|
||||
/* hopefully not needed but does not hurt anything. */
|
||||
num_loops++;
|
||||
if (num_loops > 1000)
|
||||
{
|
||||
retval = FALSE;
|
||||
break;
|
||||
}
|
||||
if (gps_read(qth->gps_data, NULL, 0) > 0)
|
||||
{
|
||||
/* handling packet_set inline with
|
||||
http://gpsd.berlios.de/client-howto.html
|
||||
*/
|
||||
if (qth->gps_data->set & PACKET_SET)
|
||||
{
|
||||
if (qth->gps_data->fix.mode >= MODE_2D)
|
||||
{
|
||||
if (qth->lat != qth->gps_data->fix.latitude)
|
||||
{
|
||||
qth->lat = qth->gps_data->fix.latitude;
|
||||
retval = TRUE;
|
||||
}
|
||||
if (qth->lon != qth->gps_data->fix.longitude)
|
||||
{
|
||||
qth->lon = qth->gps_data->fix.longitude;
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (qth->gps_data->fix.mode == MODE_3D)
|
||||
{
|
||||
if (qth->alt != qth->gps_data->fix.altitude)
|
||||
{
|
||||
qth->alt = qth->gps_data->fix.altitude;
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (qth->alt != 0)
|
||||
{
|
||||
qth->alt = 0;
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -681,6 +735,29 @@ gboolean qth_data_update_init(qth_t * qth)
|
|||
g_free(port);
|
||||
#endif
|
||||
break;
|
||||
case 11:
|
||||
#if GPSD_API_MAJOR_VERSION==11 /* for libgps 3.22 */
|
||||
/* open the connection to gpsd and start the stream */
|
||||
qth->gps_data = g_try_new0(struct gps_data_t, 1);
|
||||
|
||||
port = g_strdup_printf("%d", qth->gpsd_port);
|
||||
if (gps_open(qth->gpsd_server, port, qth->gps_data) == -1)
|
||||
{
|
||||
free(qth->gps_data);
|
||||
qth->gps_data = NULL;
|
||||
sat_log_log(SAT_LOG_LEVEL_ERROR,
|
||||
_("%s: Could not open gpsd at %s:%d"),
|
||||
__func__, qth->gpsd_server, qth->gpsd_port);
|
||||
retval = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)gps_stream(qth->gps_data, WATCH_ENABLE, NULL);
|
||||
retval = TRUE;
|
||||
}
|
||||
g_free(port);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
sat_log_log(SAT_LOG_LEVEL_ERROR,
|
||||
_("%s: Unsupported gpsd api major version (%d)"),
|
||||
|
|
@ -731,6 +808,11 @@ void qth_data_update_stop(qth_t * qth)
|
|||
gps_close(qth->gps_data);
|
||||
#endif
|
||||
break;
|
||||
case 11: /* for libgps 3.22 */
|
||||
#if GPSD_API_MAJOR_VERSION==11
|
||||
gps_close(qth->gps_data);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue