protected bool on_input_data(IOChannel source, IOCondition condition)
{
- while (libgps.waiting(ref data))
+ int res = libgps.poll(ref data);
+ if (res != 0)
+ zavai.log.error(libgps.errstr(res));
+
+ if (data.status != old_fix_status)
+ {
+ fix_status_changed(data.status);
+ old_fix_status = data.status;
+ }
+
+ uint cur_time = (uint)data.fix.time;
+ if (data.status != libgps.STATUS_NO_FIX && old_time != cur_time)
+ {
+ time_changed(cur_time);
+ old_time = cur_time;
+ }
+
+ double lat = (data.status == libgps.STATUS_NO_FIX ? 1000 : data.fix.latitude);
+ double lon = (data.status == libgps.STATUS_NO_FIX ? 1000 : data.fix.longitude);
+ if (lat != old_lat || lon != old_lon)
+ pos_changed();
+
+ /*
+ stderr.printf("GPSMSG %d %d\n", (int)data.set, data.status);
+ stderr.printf("SATUSED %d\n", data.satellites_used);
+ stderr.printf("SWT %f\n", data.skyview_time);
+ stderr.printf("SATVIS %d\n", data.satellites_visible);
+ for (int i = 0; i < data.satellites_visible; ++i)
{
- int res = libgps.poll(ref data);
- if (res != 0)
- zavai.log.error(libgps.errstr(res));
-
- if (data.status != old_fix_status)
- {
- fix_status_changed(data.status);
- old_fix_status = data.status;
- }
-
- uint cur_time = (uint)data.fix.time;
- if (data.status != libgps.STATUS_NO_FIX && old_time != cur_time)
- {
- time_changed(cur_time);
- old_time = cur_time;
- }
-
- double lat = (data.status == libgps.STATUS_NO_FIX ? 1000 : data.fix.latitude);
- double lon = (data.status == libgps.STATUS_NO_FIX ? 1000 : data.fix.longitude);
- if (lat != old_lat || lon != old_lon)
- pos_changed();
-
- stderr.printf("GPSMSG %d %d\n", (int)data.set, data.status);
- stderr.printf("SATUSED %d\n", data.satellites_used);
- stderr.printf("SWT %f\n", data.skyview_time);
- stderr.printf("SATVIS %d\n", data.satellites_visible);
- for (int i = 0; i < data.satellites_visible; ++i)
- {
- stderr.printf("PRN %d ELE %d AZI %d SS %f\n",
- data.PRN[i], data.elevation[i], data.azimuth[i], data.ss[i]);
- }
- /*
- */
+ stderr.printf("PRN %d ELE %d AZI %d SS %f\n",
+ data.PRN[i], data.elevation[i], data.azimuth[i], data.ss[i]);
}
+ */
return true;
}
return;
}
- res = libgps.send(ref data, "?SKY;");
+ //res = libgps.send(ref data, "?SKY;");
//res = libgps.send(ref data, "?WATCH;");
//if (res != 0) zavai.log.error(libgps.errstr(res));
public class GPX : Service
{
protected uint wpt_seq = 0;
- protected uint log_id = 0;
+ protected zavai.log.Log log = null;
public GPX()
{
{
if (!started)
{
- log_id = log.log.start("track", "GPS track");
+ log = zavai.log.log.start("track", "GPS track");
base.start();
}
}
{
if (started)
{
- log.log.end(log_id);
- log_id = 0;
+ zavai.log.log.end(log);
+ log = null;
base.stop();
}
}
// Mark a waypoint
public void waypoint(string? name = null)
{
- if (log_id == 0) return;
+ if (log == null) return;
string wptname;
if (name == null)
wptname = name;
}
- log.log.add(log_id, wptname);
+ log.add(wptname);
}
}