2 * Copyright (C) 2005 Alfredo Pironti
4 * This software is distributed under a BSD-style license. See the
5 * file "COPYING" in the top-level directory of the distribution for details.
9 /* This simple program shows the basic functionality of the C++ wrapper class */
19 static void callback(struct gps_data_t* p, char* buf, size_t len);
24 struct gps_data_t *resp;
28 cout << "Error opening gpsd\n";
33 cout << "Going to set the callback...\n";
34 if (gps_rec.set_callback(callback)!=0 ) {
35 cout << "Error setting callback.\n";
39 cout << "Callback setted, sleeping...\n";
41 cout << "Exited from sleep...\n";
45 if (gps_rec.del_callback()!=0) {
46 cout << "Error deleting callback\n";
49 cout << "Sleeping again, to make sure the callback is disabled\n";
58 static void callback(struct gps_data_t* p, char* buf, size_t len) {
60 cout << "Error polling gpsd\n";
63 cout << "Online:\t" << p->online << "\n";
64 cout << "Status:\t" << p->status << "\n";
65 cout << "Mode:\t" << p->fix.mode << "\n";
66 if (p->fix.mode>=MODE_2D) {
67 if (p->set & LATLON_SET) {
68 cout << "LatLon changed\n";
71 cout << "LatLon unchanged\n";
73 cout << "Longitude:\t" << p->fix.longitude <<"\n";
74 cout << "Latitude:\t" << p->fix.latitude <<"\n";