317
316
if (netgnss_uri_check(session->gpsdata.dev.path)) {
318
317
session->gpsdata.gps_fd = netgnss_uri_open(session->context,
319
318
session->gpsdata.dev.path);
320
session->sourcetype = source_socket;
319
session->sourcetype = source_tcp;
321
320
gpsd_report(LOG_SPIN,
322
321
"netgnss_uri_open(%s) returns socket on fd %d\n",
323
322
session->gpsdata.dev.path, session->gpsdata.gps_fd);
324
/* otherwise, could be an AIS data feed */
325
} else if (strncmp(session->gpsdata.dev.path, "ais://", 6) == 0) {
323
/* otherwise, could be an TCP data feed */
324
} else if (strncmp(session->gpsdata.dev.path, "tcp://", 6) == 0) {
326
325
char server[GPS_PATH_MAX], *port;
328
327
(void)strlcpy(server, session->gpsdata.dev.path + 6, sizeof(server));
329
328
session->gpsdata.gps_fd = -1;
330
329
port = strchr(server, ':');
331
330
if (port == NULL) {
332
gpsd_report(LOG_ERROR, "Missing colon in AIS feed spec.\n");
331
gpsd_report(LOG_ERROR, "Missing colon in TCP feed spec.\n");
336
gpsd_report(LOG_INF, "opening AIS feed at %s, port %s.\n", server,
335
gpsd_report(LOG_INF, "opening TCP feed at %s, port %s.\n", server,
338
337
if ((dsock = netlib_connectsock(AF_UNSPEC, server, port, "tcp")) < 0) {
339
gpsd_report(LOG_ERROR, "AIS device open error %s.\n",
340
netlib_errstr(dsock));
343
session->gpsdata.gps_fd = dsock;
338
gpsd_report(LOG_ERROR, "TCP device open error %s.\n",
339
netlib_errstr(dsock));
342
session->gpsdata.gps_fd = dsock;
343
session->sourcetype = source_tcp;
344
} else if (strncmp(session->gpsdata.dev.path, "udp://", 6) == 0) {
345
char server[GPS_PATH_MAX], *port;
347
(void)strlcpy(server, session->gpsdata.dev.path + 6, sizeof(server));
348
session->gpsdata.gps_fd = -1;
349
port = strchr(server, ':');
351
gpsd_report(LOG_ERROR, "Missing colon in UDP feed spec.\n");
355
gpsd_report(LOG_INF, "opening UDP feed at %s, port %s.\n", server,
357
if ((dsock = netlib_connectsock(AF_UNSPEC, server, port, "udp")) < 0) {
358
gpsd_report(LOG_ERROR, "UDP device open error %s.\n",
359
netlib_errstr(dsock));
362
session->gpsdata.gps_fd = dsock;
363
session->sourcetype = source_udp;
345
365
/* otherwise, ordinary serial device */
486
507
(session->gpsdata.status ==
487
508
STATUS_DGPS_FIX ? P_UERE_WITH_DGPS : P_UERE_NO_DGPS);
491
* OK, this is not an error computation, but
492
* we're at the right place in the architrcture for it.
493
* Compute climb/sink in the simplest possible way.
494
* FIXME: Someday we should compute speed here too.
511
* OK, this is not an error computation, but we're at the right
512
* place in the architecture for it. Compute speed over ground
513
* and climb/sink in the simplest possible way.
515
if (fix->mode >= MODE_2D && oldfix->mode >= MODE_2D
516
&& isnan(fix->speed) != 0) {
517
if (fix->time == oldfix->time)
521
earth_distance(fix->latitude, fix->longitude,
522
oldfix->latitude, oldfix->longitude)
523
/ (fix->time - oldfix->time);
496
525
if (fix->mode >= MODE_3D && oldfix->mode >= MODE_3D
497
526
&& isnan(fix->climb) != 0) {
498
527
if (fix->time == oldfix->time)
627
656
gpsd_report(LOG_RAW,
628
657
"packet sniff on %s finds type %d\n",
629
658
session->gpsdata.dev.path, session->packet.type);
630
if (session->packet.type > COMMENT_PACKET) {
659
if (session->packet.type == COMMENT_PACKET) {
660
gpsd_report (LOG_PROG, "comment, sync lock deferred\n");
661
} else if (session->packet.type > COMMENT_PACKET) {
631
662
first_sync = (session->device_type == NULL);
632
663
for (dp = gpsd_drivers; *dp; dp++)
633
664
if (session->packet.type == (*dp)->packet_type) {
634
665
(void)gpsd_switch_driver(session, (*dp)->type_name);
637
} else if (!gpsd_next_hunt_setting(session))
668
} else if (session->getcount++ > 1 && !gpsd_next_hunt_setting(session))
641
672
/* update the scoreboard structure from the GPS */
642
673
gpsd_report(LOG_RAW + 2, "%s sent %zd new characters\n",
643
674
session->gpsdata.dev.path, newlen);
644
if (newlen <= 0) { /* read error or EOF */
675
if (newlen < 0) { /* read error */
676
gpsd_report(LOG_INF, "GPS on %s returned error %zd (%lf sec since data)\n",
677
session->gpsdata.dev.path, newlen,
678
timestamp() - session->gpsdata.online);
679
session->gpsdata.online = 0;
681
} else if (newlen == 0) { /* zero length read, possible EOF */
645
682
gpsd_report(LOG_INF, "GPS on %s is offline (%lf sec since data)\n",
646
683
session->gpsdata.dev.path,
647
684
timestamp() - session->gpsdata.online);
648
685
session->gpsdata.online = 0;
650
687
} else if (session->packet.outbuflen == 0) { /* got new data, but no packet */
651
688
gpsd_report(LOG_RAW + 3, "New data on %s, not yet a packet\n",
652
689
session->gpsdata.dev.path);
689
726
* If this is the first time we've achieved sync on this
690
* device, or the the driver type has changed for any other
727
* device, or the driver type has changed for any other
691
728
* reason, that's a significant event that the caller needs to
692
* know about. Using DEVICE_IS this way is a bit shaky but
693
* we're short of bits in the flag mask (client library uses
696
731
if (first_sync || session->notify_clients) {
697
732
session->notify_clients = false;
698
received |= DEVICE_IS;
733
received |= DRIVER_IS;
701
736
/* Get data from current packet into the fix structure */