return sensor / 4095.0 * supply * (5.6 + 10.0) / 10.0;
}
+ static double tele_gps_3_voltage(int sensor) {
+ double supply = 3.3;
+
+ return sensor / 32767.0 * supply * (5.6 + 10.0) / 10.0;
+ }
+
static double tele_bt_3_battery(int raw) {
if (raw == AltosLib.MISSING)
return AltosLib.MISSING;
if (bits.length < 2)
return false;
alt = Integer.parseInt(bits[1]);
+ } else if (line.startsWith("Pdop/Hdop/Vdop:")) {
+ if (bits.length < 4)
+ return false;
+ pdop = Integer.parseInt(bits[1]) / 10.0;
+ hdop = Integer.parseInt(bits[2]) / 10.0;
+ vdop = Integer.parseInt(bits[3]) / 10.0;
+ } else if (line.startsWith("Ground Speed/Climb Rate/Course:")) {
+ if (bits.length < 6)
+ return false;
+ ground_speed = Integer.parseInt(bits[3]) * 1.0e-2;
+ climb_rate = Integer.parseInt(bits[4]) * 1.0e-2;
+ course = Integer.parseInt(bits[5]) * 2;
} else if (line.startsWith("Flags:")) {
if (bits.length < 2)
return false;
int status = Integer.decode(bits[1]);
connected = (status & AltosLib.AO_GPS_RUNNING) != 0;
locked = (status & AltosLib.AO_GPS_VALID) != 0;
+ nsat = (status >> AltosLib.AO_GPS_NUM_SAT_SHIFT) & AltosLib.AO_GPS_NUM_SAT_MASK;
if (!says_done)
return false;
} else if (line.startsWith("Sats:")) {
if (bits.length < 2)
return false;
- nsat = Integer.parseInt(bits[1]);
- cc_gps_sat = new AltosGPSSat[nsat];
- for (int i = 0; i < nsat; i++) {
+ int nsvs = Integer.parseInt(bits[1]);
+ cc_gps_sat = new AltosGPSSat[nsvs];
+ for (int i = 0; i < nsvs; i++) {
int svid = Integer.parseInt(bits[2+i*2]);
int cc_n0 = Integer.parseInt(bits[3+i*2]);
cc_gps_sat[i] = new AltosGPSSat(svid, cc_n0);
static final int idle_sensor_tmini2 = 105;
static final int idle_sensor_tgps1 = 106;
static final int idle_sensor_tgps2 = 107;
- static final int idle_sensor_tmini3 = 108;
- static final int idle_sensor_easytimer1 = 109;
- static final int idle_sensor_easymotor2 = 110;
+ static final int idle_sensor_tgps3 = 108;
+ static final int idle_sensor_tmini3 = 109;
+ static final int idle_sensor_easytimer1 = 110;
+ static final int idle_sensor_easymotor2 = 111;
public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException, TimeoutException, AltosUnknownProduct {
for (int idler : idlers) {
case idle_sensor_tgps2:
AltosSensorTGPS2.provide_data(listener, link);
break;
+ case idle_sensor_tgps3:
+ AltosSensorTGPS3.provide_data(listener, link);
+ break;
case idle_sensor_tmini3:
AltosSensorTMini3.provide_data(listener, link);
break;
new AltosIdler("TeleGPS-v2",
AltosIdler.idle_gps,
AltosIdler.idle_sensor_tgps2),
+ new AltosIdler("TeleGPS-v3",
+ AltosIdler.idle_gps,
+ AltosIdler.idle_sensor_tgps3),
new AltosIdler("EasyTimer-v1",
AltosIdler.idle_imu_et_v1,
AltosIdler.idle_sensor_easytimer1),
--- /dev/null
+/*
+ * Copyright © 2015 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altoslib_14;
+
+import java.util.concurrent.TimeoutException;
+
+public class AltosSensorTGPS3 {
+ public int tick;
+ public int batt;
+
+ static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
+ try {
+ AltosSensorTGPS3 sensor_tgps = new AltosSensorTGPS3(link);
+
+ if (sensor_tgps == null)
+ return;
+ listener.set_battery_voltage(AltosConvert.tele_gps_3_voltage(sensor_tgps.batt));
+
+ } catch (TimeoutException te) {
+ }
+ }
+
+ public AltosSensorTGPS3(AltosLink link) throws InterruptedException, TimeoutException {
+ String[] items = link.adc();
+ for (int i = 0; i < items.length - 1;) {
+ if (items[i].equals("tick:")) {
+ tick = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("batt:")) {
+ batt = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ i++;
+ }
+ }
+}
+
AltosSensorMetrum.java \
AltosSensorTGPS1.java \
AltosSensorTGPS2.java \
+ AltosSensorTGPS3.java \
AltosSensorEasyMotor2.java \
AltosState.java \
AltosStateName.java \
#define AO_UBLOX_DEBUG 0
+#ifndef AO_UBLOX_VERSION
+#define AO_UBLOX_VERSION 8
+#endif
+
#include <stdarg.h>
uint8_t ao_gps_new;
#define DBG_CHAR 2
#define DBG_INIT 4
-static uint8_t ao_gps_dbg_enable = DBG_PROTO|DBG_CHAR|DBG_INIT;
+static uint8_t ao_gps_dbg_enable = 0;
static void ao_gps_dbg(int level, char *format, ...) {
va_list a;
*ptr = val;
}
-static void ublox_u32(uint8_t offset)
+static void ublox_u32(uint8_t offset)
{
uint32_t *ptr = (uint32_t *) (void *) (ublox_target + offset);
uint32_t val;
};
static void
-ao_ublox_parse(void *target, const struct ublox_packet_parse *parse)
+ao_ublox_parse(void *target, const struct ublox_packet_parse *parse)
{
uint8_t i, offset;
ao_ublox_parse(&nav_dop, nav_dop_packet);
}
+static const struct ublox_packet_parse ack_ack_packet[] = {
+ { UBLOX_DISCARD, 2 }, /* 0 class ID, msg ID */
+ { UBLOX_END, 0 },
+};
+
+static void
+ao_ublox_parse_ack_ack(void)
+{
+ ao_ublox_parse(NULL, ack_ack_packet);
+}
+
+static struct ack_nak {
+ uint8_t class_id;
+ uint8_t msg_id;
+} ack_nak;
+
+static const struct ublox_packet_parse ack_nak_packet[] = {
+ { UBLOX_U8, offsetof(struct ack_nak, class_id) }, /* 0 class ID */
+ { UBLOX_U8, offsetof(struct ack_nak, msg_id) }, /* 1 msg ID */
+ { UBLOX_END, 0 },
+};
+
+static void
+ao_ublox_parse_ack_nak(void)
+{
+ ao_ublox_parse(&ack_nak, ack_nak_packet);
+#if AO_UBLOX_DEBUG
+ ao_gps_dbg(DBG_PROTO, "NAK class 0x%02x msg 0x%02x\n",
+ ack_nak.class_id, ack_nak.msg_id);
+#endif
+}
+
+#if AO_UBLOX_VERSION < 10
/*
* NAV-POSLLH message parsing
*/
ao_ublox_parse(&nav_velned, nav_velned_packet);
}
+#else /* AO_UBLOX_VERSION < 10 */
+
+/*
+ * NAV-PVT message parsing
+ */
+
+static struct nav_pvt {
+ uint16_t year;
+ uint8_t month;
+ uint8_t day;
+ uint8_t hour;
+ uint8_t min;
+ uint8_t sec;
+ uint8_t valid;
+ int32_t nano;
+ uint8_t flags;
+ uint8_t num_sv;
+ int32_t lat;
+ int32_t lon;
+ int32_t alt_msl;
+ int32_t vel_d;
+ int32_t g_speed;
+ int32_t heading;
+} nav_pvt;
+
+static const struct ublox_packet_parse nav_pvt_packet[] = {
+ { UBLOX_DISCARD, 4 }, /* 0 iTOW */
+ { UBLOX_U16, offsetof(struct nav_pvt, year) }, /* 4 year */
+ { UBLOX_U8, offsetof(struct nav_pvt, month) }, /* 6 month */
+ { UBLOX_U8, offsetof(struct nav_pvt, day) }, /* 7 day */
+ { UBLOX_U8, offsetof(struct nav_pvt, hour) }, /* 8 hour */
+ { UBLOX_U8, offsetof(struct nav_pvt, min) }, /* 9 min */
+ { UBLOX_U8, offsetof(struct nav_pvt, sec) }, /* 10 sec */
+ { UBLOX_U8, offsetof(struct nav_pvt, valid) }, /* 11 valid */
+ { UBLOX_DISCARD, 4 }, /* 12 tAcc */
+ { UBLOX_U32, offsetof(struct nav_pvt, nano) }, /* 16 nano */
+ { UBLOX_DISCARD, 1 }, /* 20 fixType */
+ { UBLOX_U8, offsetof(struct nav_pvt, flags) }, /* 21 gpsFix */
+ { UBLOX_DISCARD, 1 }, /* 22 flags2 */
+ { UBLOX_U8, offsetof(struct nav_pvt, num_sv) }, /* 23 numSV */
+ { UBLOX_U32, offsetof(struct nav_pvt, lon) }, /* 24 Longitude */
+ { UBLOX_U32, offsetof(struct nav_pvt, lat) }, /* 28 Latitude */
+ { UBLOX_DISCARD, 4 }, /* 32 height above ellipsoid */
+ { UBLOX_U32, offsetof(struct nav_pvt, alt_msl) }, /* 36 Height above mean sea level */
+ { UBLOX_DISCARD, 16 }, /* 40 hAcc, vAcc, velN, velE */
+ { UBLOX_U32, offsetof(struct nav_pvt, vel_d) }, /* 56 velD */
+ { UBLOX_U32, offsetof(struct nav_pvt, g_speed) }, /* 60 gSpeed */
+ { UBLOX_U32, offsetof(struct nav_pvt, heading) }, /* 64 headMot */
+ { UBLOX_DISCARD, 92 - 68 }, /* 68 sAcc .. magAcc */
+ { UBLOX_END, 0 }
+};
+
+#define NAV_PVT_VALID_DATE 0
+#define NAV_PVT_VALID_TIME 1
+#define NAV_PVT_VALID_FULLY_RESOLVED 2
+#define NAV_PVT_VALID_MAG 3
+
+#define NAV_PVT_FLAGS_GNSSFIXOK 0
+#define NAV_PVT_FLAGS_DIFFSOLN 1
+#define NAV_PVT_FLAGS_PSM_STATE 2
+#define NAV_PVT_FLAGS_HEAD_VEH_VALID 5
+#define NAV_PVT_FLAGS_CARR_SOLN 6
+
+static void
+ao_ublox_parse_nav_pvt(void)
+{
+ ao_ublox_parse(&nav_pvt, nav_pvt_packet);
+#if AO_UBLOX_DEBUG
+ ao_gps_dbg(DBG_PROTO, "\t%d-%d-%d %02d:%02d:%02d %ld (%02x)\n",
+ nav_pvt.year, nav_pvt.month, nav_pvt.day,
+ nav_pvt.hour, nav_pvt.min, nav_pvt.sec,
+ (long) nav_pvt.nano, nav_pvt.valid);
+ ao_gps_dbg(DBG_PROTO, "\tflags %02x numSV %d lon %ld lat %ld alt %ld\n",
+ nav_pvt.flags, nav_pvt.num_sv,
+ (long) nav_pvt.lon, (long) nav_pvt.lat, (long) nav_pvt.alt_msl);
+#endif
+}
+
+/*
+ * NAV-SAT message parsing
+ */
+
+static struct nav_sat {
+ uint8_t num_svs;
+} nav_sat;
+
+static const struct ublox_packet_parse nav_sat_packet[] = {
+ { UBLOX_DISCARD, 4 }, /* 0 iTOW */
+ { UBLOX_DISCARD, 1 }, /* 4 version */
+ { UBLOX_U8, offsetof(struct nav_sat, num_svs) }, /* 4 numSvs */
+ { UBLOX_DISCARD, 2 }, /* 6 reserved0 */
+ { UBLOX_END, 0 }
+};
+
+#define NAV_SAT_MAX_SAT AO_TELEMETRY_SATELLITE_MAX_SAT
+
+static struct nav_sat_sat {
+ uint8_t svid;
+ uint8_t cno;
+} nav_sat_sat[NAV_SAT_MAX_SAT];
+
+static uint8_t nav_sat_nsat;
+
+static struct nav_sat_real_sat {
+ uint8_t svid;
+ uint8_t cno;
+ uint32_t flags;
+} nav_sat_real_sat;
+
+static const struct ublox_packet_parse nav_sat_sat_packet[] = {
+ { UBLOX_DISCARD, 1 }, /* 8 + 12*N gnssid */
+ { UBLOX_U8, offsetof(struct nav_sat_real_sat, svid) }, /* 9 + 12*N svid */
+ { UBLOX_U8, offsetof(struct nav_sat_real_sat, cno) }, /* 10 + 12*N cno */
+ { UBLOX_DISCARD, 5 }, /* 11 + 12*N elev, azim, prRes */
+ { UBLOX_U32, offsetof(struct nav_sat_real_sat, flags) }, /* 16 + 12*N flags */
+ { UBLOX_END, 0 }
+};
+
+static uint32_t
+ao_ublox_sat_quality(struct nav_sat_real_sat *sat)
+{
+ return (sat->flags >> UBLOX_NAV_SAT_FLAGS_QUALITY) & UBLOX_NAV_SAT_FLAGS_QUALITY_MASK;
+}
+
+static uint32_t
+ao_ublox_sat_health(struct nav_sat_real_sat *sat)
+{
+ return (sat->flags >> UBLOX_NAV_SAT_FLAGS_SV_HEALTH) & UBLOX_NAV_SAT_FLAGS_SV_HEALTH_MASK;
+}
+
+static void
+ao_ublox_parse_nav_sat(void)
+{
+ uint8_t nsat;
+ nav_sat_nsat = 0;
+
+ ao_ublox_parse(&nav_sat, nav_sat_packet);
+ for (nsat = 0; nsat < nav_sat.num_svs && ao_ublox_len >= 12; nsat++) {
+ ao_ublox_parse(&nav_sat_real_sat, nav_sat_sat_packet);
+ if (nav_sat_nsat < NAV_SAT_MAX_SAT &&
+ ao_ublox_sat_health(&nav_sat_real_sat) == UBLOX_NAV_SAT_FLAGS_SV_HEALTH_HEALTHY &&
+ ao_ublox_sat_quality(&nav_sat_real_sat) >= UBLOX_NAV_SAT_FLAGS_QUALITY_ACQUIRED)
+ {
+ nav_sat_sat[nav_sat_nsat].svid = nav_sat_real_sat.svid;
+ nav_sat_sat[nav_sat_nsat].cno = nav_sat_real_sat.cno;
+ nav_sat_nsat++;
+ }
+ }
+#if AO_UBLOX_DEBUG
+ ao_gps_dbg(DBG_PROTO, "sat num_svs %d\n", nav_sat.num_svs);
+ for (nsat = 0; nsat < nav_sat.num_svs; nsat++) {
+ if (nsat < NAV_SAT_MAX_SAT) {
+ ao_gps_dbg(DBG_PROTO, "\t%d: svid %d cno %d\n",
+ nsat,
+ nav_sat_sat[nsat].svid,
+ nav_sat_sat[nsat].cno);
+ } else {
+ ao_gps_dbg(DBG_PROTO, "\t%d: skipped\n", nsat);
+ }
+ }
+#endif
+}
+
+#endif /* else AO_UBLOX_VERSION < 10 */
+
/*
* Set the protocol mode and baud rate
*/
static void
ao_ublox_set_message_rate(uint8_t class, uint8_t msgid, uint8_t rate)
{
- ao_ublox_putstart(0x06, 0x01, 3);
+ ao_ublox_putstart(UBLOX_CFG, UBLOX_CFG_MSG, 3);
ao_ublox_put_u8(class);
ao_ublox_put_u8(msgid);
ao_ublox_put_u8(rate);
ao_ublox_putend();
}
-
/*
* Disable all MON message
*/
* Enable enough messages to get all of the data we want
*/
static const uint8_t ublox_enable_nav[] = {
- UBLOX_NAV_DOP,
- UBLOX_NAV_POSLLH,
- UBLOX_NAV_SOL,
- UBLOX_NAV_SVINFO,
- UBLOX_NAV_VELNED,
- UBLOX_NAV_TIMEUTC
+ UBLOX_NAV_DOP, /* both */
+#if AO_UBLOX_VERSION >= 10
+ UBLOX_NAV_PVT, /* new */
+ UBLOX_NAV_SAT, /* new */
+#else
+ UBLOX_NAV_POSLLH, /* both, but redundant with PVT */
+ UBLOX_NAV_SOL, /* old */
+ UBLOX_NAV_SVINFO, /* old */
+ UBLOX_NAV_VELNED, /* both, but redundant with PVT */
+ UBLOX_NAV_TIMEUTC /* both, but redundant with PVT */
+#endif
};
void
}
void
-ao_gps(void)
+ao_gps(void)
{
uint8_t class, id;
struct ao_ublox_cksum cksum;
if (ao_ublox_len > 1023)
continue;
+ bool gps_ready = false;
+
switch (class) {
case UBLOX_NAV:
switch (id) {
if (ao_ublox_len != 18)
break;
ao_ublox_parse_nav_dop();
+#if AO_UBLOX_VERSION >= 10
+ gps_ready = true;
+#endif
+ break;
+#if AO_UBLOX_VERSION >= 10
+ case UBLOX_NAV_PVT:
+ if (ao_ublox_len != 92)
+ break;
+ ao_ublox_parse_nav_pvt();
+ solution_tick = packet_start_tick;
break;
+ case UBLOX_NAV_SAT:
+ if (ao_ublox_len < 8)
+ break;
+ ao_ublox_parse_nav_sat();
+ break;
+#else
case UBLOX_NAV_POSLLH:
if (ao_ublox_len != 28)
break;
if (ao_ublox_len != 20)
break;
ao_ublox_parse_nav_timeutc();
+ gps_ready = true;
break;
+#endif
}
break;
+ case UBLOX_ACK:
+ switch (id) {
+ case UBLOX_ACK_ACK:
+ if (ao_ublox_len != 2)
+ break;
+ ao_ublox_parse_ack_ack();
+ break;
+ case UBLOX_ACK_NAK:
+ if (ao_ublox_len != 2)
+ break;
+ ao_ublox_parse_ack_nak();
+ break;
+ }
}
if (ao_ublox_len != 0) {
if (ao_ublox_cksum.a != cksum.a || ao_ublox_cksum.b != cksum.b)
continue;
- switch (class) {
- case UBLOX_NAV:
- switch (id) {
- case UBLOX_NAV_TIMEUTC:
- ao_mutex_get(&ao_gps_mutex);
- ao_gps_tick = solution_tick;
- ao_gps_utc_tick = packet_start_tick + (AO_TICK_TYPE) AO_NS_TO_TICKS(nav_timeutc.nano);
- ao_gps_data.flags = 0;
- ao_gps_data.flags |= AO_GPS_RUNNING;
- if (nav_sol.gps_fix & (1 << NAV_SOL_FLAGS_GPSFIXOK)) {
- uint8_t nsat = nav_sol.nsat;
- ao_gps_data.flags |= AO_GPS_VALID | AO_GPS_COURSE_VALID;
- if (nsat > 15)
- nsat = 15;
- ao_gps_data.flags |= nsat;
- }
- if (nav_timeutc.valid & (1 << NAV_TIMEUTC_VALID_UTC))
- ao_gps_data.flags |= AO_GPS_DATE_VALID;
-
- AO_TELEMETRY_LOCATION_SET_ALTITUDE(&ao_gps_data, nav_posllh.alt_msl / 1000);
- ao_gps_data.latitude = nav_posllh.lat;
- ao_gps_data.longitude = nav_posllh.lon;
-
- ao_gps_data.year = (uint8_t) (nav_timeutc.year - 2000);
- ao_gps_data.month = nav_timeutc.month;
- ao_gps_data.day = nav_timeutc.day;
-
- ao_gps_data.hour = nav_timeutc.hour;
- ao_gps_data.minute = nav_timeutc.min;
- ao_gps_data.second = nav_timeutc.sec;
-
- /* we report dop scaled by 10, but ublox provides dop scaled by 100
- */
- ao_gps_data.pdop = (uint8_t) (nav_dop.pdop / 10);
- ao_gps_data.hdop = (uint8_t) (nav_dop.hdop / 10);
- ao_gps_data.vdop = (uint8_t) (nav_dop.vdop / 10);
-
- ao_gps_data.ground_speed = (uint16_t) nav_velned.g_speed;
- ao_gps_data.climb_rate = -(int16_t) nav_velned.vel_d;
- ao_gps_data.course = (uint8_t) (nav_velned.heading / 200000);
-
- ao_gps_tracking_data.channels = 0;
-
- struct ao_telemetry_satellite_info *dst = &ao_gps_tracking_data.sats[0];
- struct nav_svinfo_sat *src = &nav_svinfo_sat[0];
-
- for (i = 0; i < nav_svinfo_nsat; i++) {
- if (!(src->flags & (1 << NAV_SVINFO_SAT_FLAGS_UNHEALTHY)) &&
- src->quality >= NAV_SVINFO_SAT_QUALITY_ACQUIRED)
- {
- if (ao_gps_tracking_data.channels < AO_TELEMETRY_SATELLITE_MAX_SAT) {
- dst->svid = src->svid;
- dst->c_n_1 = src->cno;
- dst++;
- ao_gps_tracking_data.channels++;
- }
- }
- src++;
- }
+ if (!gps_ready)
+ continue;
- ao_mutex_put(&ao_gps_mutex);
- ao_gps_new = AO_GPS_NEW_DATA | AO_GPS_NEW_TRACKING;
- ao_wakeup(&ao_gps_new);
- break;
+ ao_mutex_get(&ao_gps_mutex);
+ ao_gps_data.flags = 0;
+ ao_gps_data.flags |= AO_GPS_RUNNING;
+ ao_gps_tick = solution_tick;
+
+ /* we report dop scaled by 10, but ublox provides dop scaled by 100
+ */
+ ao_gps_data.pdop = (uint8_t) (nav_dop.pdop / 10);
+ ao_gps_data.hdop = (uint8_t) (nav_dop.hdop / 10);
+ ao_gps_data.vdop = (uint8_t) (nav_dop.vdop / 10);
+
+#if AO_UBLOX_VERSION >= 10
+ ao_gps_utc_tick = packet_start_tick + (AO_TICK_TYPE) AO_NS_TO_TICKS(nav_pvt.nano);
+ if (nav_pvt.flags & (1 << NAV_PVT_FLAGS_GNSSFIXOK)) {
+ uint8_t nsat = nav_pvt.num_sv;
+ ao_gps_data.flags |= AO_GPS_VALID | AO_GPS_COURSE_VALID;
+ if (nsat > 15)
+ nsat = 15;
+ ao_gps_data.flags |= nsat;
+ }
+ if (nav_pvt.valid & (1 << NAV_PVT_VALID_DATE))
+ ao_gps_data.flags |= AO_GPS_DATE_VALID;
+ AO_TELEMETRY_LOCATION_SET_ALTITUDE(&ao_gps_data, nav_pvt.alt_msl / 1000);
+ ao_gps_data.latitude = nav_pvt.lat;
+ ao_gps_data.longitude = nav_pvt.lon;
+
+ ao_gps_data.year = (uint8_t) (nav_pvt.year - 2000);
+ ao_gps_data.month = nav_pvt.month;
+ ao_gps_data.day = nav_pvt.day;
+
+ ao_gps_data.hour = nav_pvt.hour;
+ ao_gps_data.minute = nav_pvt.min;
+ ao_gps_data.second = nav_pvt.sec;
+
+ /* ublox speeds are mm/s */
+ ao_gps_data.ground_speed = (uint16_t) (nav_pvt.g_speed / 10);
+ ao_gps_data.climb_rate = -(int16_t) (nav_pvt.vel_d / 10);
+ ao_gps_data.course = (uint8_t) (nav_pvt.heading / 200000);
+#else
+ ao_gps_utc_tick = packet_start_tick + (AO_TICK_TYPE) AO_NS_TO_TICKS(nav_timeutc.nano);
+ if (nav_sol.gps_fix & (1 << NAV_SOL_FLAGS_GPSFIXOK)) {
+ uint8_t nsat = nav_sol.nsat;
+ ao_gps_data.flags |= AO_GPS_VALID | AO_GPS_COURSE_VALID;
+ if (nsat > 15)
+ nsat = 15;
+ ao_gps_data.flags |= nsat;
+ }
+ if (nav_timeutc.valid & (1 << NAV_TIMEUTC_VALID_UTC))
+ ao_gps_data.flags |= AO_GPS_DATE_VALID;
+
+ AO_TELEMETRY_LOCATION_SET_ALTITUDE(&ao_gps_data, nav_posllh.alt_msl / 1000);
+ ao_gps_data.latitude = nav_posllh.lat;
+ ao_gps_data.longitude = nav_posllh.lon;
+
+ ao_gps_data.year = (uint8_t) (nav_timeutc.year - 2000);
+ ao_gps_data.month = nav_timeutc.month;
+ ao_gps_data.day = nav_timeutc.day;
+
+ ao_gps_data.hour = nav_timeutc.hour;
+ ao_gps_data.minute = nav_timeutc.min;
+ ao_gps_data.second = nav_timeutc.sec;
+
+ /* ublox speeds are cm/s */
+ ao_gps_data.ground_speed = (uint16_t) nav_velned.g_speed;
+ ao_gps_data.climb_rate = -(int16_t) nav_velned.vel_d;
+ ao_gps_data.course = (uint8_t) (nav_velned.heading / 200000);
+#endif
+
+ ao_gps_tracking_data.channels = 0;
+
+ struct ao_telemetry_satellite_info *dst = &ao_gps_tracking_data.sats[0];
+#if AO_UBLOX_VERSION >= 10
+ struct nav_sat_sat *src = &nav_sat_sat[0];
+
+ for (i = 0; i < nav_sat_nsat; i++) {
+ if (ao_gps_tracking_data.channels < AO_TELEMETRY_SATELLITE_MAX_SAT) {
+ dst->svid = src->svid;
+ dst->c_n_1 = src->cno;
+ dst++;
+ ao_gps_tracking_data.channels++;
}
- break;
+ src++;
+ }
+#else
+ struct nav_svinfo_sat *src = &nav_svinfo_sat[0];
+
+ for (i = 0; i < nav_svinfo_nsat; i++) {
+ if (!(src->flags & (1 << NAV_SVINFO_SAT_FLAGS_UNHEALTHY)) &&
+ src->quality >= NAV_SVINFO_SAT_QUALITY_ACQUIRED)
+ {
+ if (ao_gps_tracking_data.channels < AO_TELEMETRY_SATELLITE_MAX_SAT) {
+ dst->svid = src->svid;
+ dst->c_n_1 = src->cno;
+ dst++;
+ ao_gps_tracking_data.channels++;
+ }
+ }
+ src++;
}
+#endif
+ ao_mutex_put(&ao_gps_mutex);
+ ao_gps_new = AO_GPS_NEW_DATA | AO_GPS_NEW_TRACKING;
+ ao_wakeup(&ao_gps_new);
}
}
uint16_t length;
};
+#define UBLOX_ACK 0x05
+
+#define UBLOX_ACK_NAK 0x00
+#define UBLOX_ACK_ACK 0x01
+
#define UBLOX_NAV 0x01
#define UBLOX_NAV_DOP 0x04
#define UBLOX_NAV_SOL_FLAGS_WKNSET 2
#define UBLOX_NAV_SOL_FLAGS_TOWSET 3
+#define UBLOX_NAV_PVT 0x07
+
#define UBLOX_NAV_STATUS 0x03
struct ublox_nav_status {
uint32_t cacc; /* deg */
};
+#define UBLOX_NAV_SAT 0x35
+
+struct ublox_nav_sat {
+ uint8_t class; /* 0x01 */
+ uint8_t message; /* 0x35 */
+ uint16_t length; /* 8 + 12 * numsvs */
+
+ uint32_t itow; /* time of week */
+ uint8_t version; /* Message version (0x01) */
+ uint8_t numSvs; /* number of satellites */
+ uint16_t reserved;
+};
+
+struct ublox_nav_sat_sat {
+ uint8_t gnssId; /* GNSS identifier */
+ uint8_t svId; /* satellite identifier */
+ uint8_t cno; /* carrier to noise ratio */
+ int8_t elev; /* elevation */
+ int16_t azim; /* azimuth */
+ int16_t prRes; /* pseudorange residual */
+ uint32_t flags;
+};
+
+#define UBLOX_NAV_SAT_FLAGS_QUALITY 0
+#define UBLOX_NAV_SAT_FLAGS_QUALITY_NO_SIGNAL 0
+#define UBLOX_NAV_SAT_FLAGS_QUALITY_SEARCHING 1
+#define UBLOX_NAV_SAT_FLAGS_QUALITY_ACQUIRED 2
+#define UBLOX_NAV_SAT_FLAGS_QUALITY_UNUSABLE 3
+#define UBLOX_NAV_SAT_FLAGS_QUALITY_CODE_LOCKED 4
+#define UBLOX_NAV_SAT_FLAGS_QUALITY_CARRIER_LOCKED 5
+#define UBLOX_NAV_SAT_FLAGS_QUALITY_MASK 7
+#define UBLOX_NAV_SAT_FLAGS_SV_USED 3
+#define UBLOX_NAV_SAT_FLAGS_SV_HEALTH 4
+#define UBLOX_NAV_SAT_FLAGS_SV_HEALTH_UNKNOWN 0
+#define UBLOX_NAV_SAT_FLAGS_SV_HEALTH_HEALTHY 1
+#define UBLOX_NAV_SAT_FLAGS_SV_HEALTH_UNHEALTHY 2
+#define UBLOX_NAV_SAT_FLAGS_SV_HEALTH_MASK 3
+#define UBLOX_NAV_SAT_FLAGS_DIFF_CORR 6
+#define UBLOX_NAV_SAT_FLAGS_SMOOTHED 7
+#define UBLOX_NAV_SAT_FLAGS_ORBIT_SOURCE 8
+#define UBLOX_NAV_SAT_FLAGS_ORBIT_SOURCE_NONE 0
+#define UBLOX_NAV_SAT_FLAGS_ORBIT_SOURCE_EPHEMERIS 1
+#define UBLOX_NAV_SAT_FLAGS_ORBIT_SOURCE_ALMANAC 2
+#define UBLOX_NAV_SAT_FLAGS_ORBIT_SOURCE_ASSIST_NOW_OFFLINE 3
+#define UBLOX_NAV_SAT_FLAGS_ORBIT_SOURCE_ASSIST_NOW_AUTONOMOUS 4
+#define UBLOX_NAV_SAT_FLAGS_ORBIT_SOURCE_MASK 7
+#define UBLOX_NAV_SAT_FLAGS_EPH_AVAILABLE 11
+#define UBLOX_NAV_SAT_FLAGS_ALM_AVAILABLE 12
+#define UBLOX_NAV_SAT_FLAGS_ANO_AVAILABLE 13
+#define UBLOX_NAV_SAT_FLAGS_AOP_AVAILABLE 14
+#define UBLOX_NAV_SAT_FLAGS_SBAS_CORR_USED 16
+#define UBLOX_NAV_SAT_FLAGS_RTCM_CORR_USED 17
+#define UBLOX_NAV_SAT_FLAGS_SLAS_CORR_USED 18
+#define UBLOX_NAV_SAT_FLAGS_SPARTN_CORR_USED 19
+#define UBLOX_NAV_SAT_FLAGS_PR_CORR_USED 20
+#define UBLOX_NAV_SAT_FLAGS_CR_CORR_USED 21
+#define UBLOX_NAV_SAT_FLAGS_DO_CORR_USED 22
#define UBLOX_CFG 0x06
#define UBLOX_CFG_NAV5 0x24
#define UBLOX_CFG_NAV5_FIXMODE_3D 2
#define UBLOX_CFG_NAV5_FIXMODE_AUTO 3
+#define UBLOX_CFG_MSG 0x01
+#define UBLOX_CFG_VALSET 0x8a
+#define UBLOX_CFG_VALSET_VERSION 0x00
+#define UBLOX_CFG_VALSET_LAYER_RAM 0x01
+#define UBLOX_CFG_VALSET_LAYER_BBR 0x02
+#define UBLOX_CFG_VALSET_LAYER_FLASH 0x04
+
+#define UBLOX_CFG_MSGOUT_NMEA_ID_DTM_I2C 0x209100a6 /* U1 -- Output rate of the NMEA-GX-DTM message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_DTM_SPI 0x209100aa /* U1 -- Output rate of the NMEA-GX-DTM message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_DTM_UART1 0x209100a7 /* U1 -- Output rate of the NMEA-GX-DTM message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GBS_I2C 0x209100dd /* U1 -- Output rate of the NMEA-GX-GBS message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GBS_SPI 0x209100e1 /* U1 -- Output rate of the NMEA-GX-GBS message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GBS_UART1 0x209100de /* U1 -- Output rate of the NMEA-GX-GBS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GGA_I2C 0x209100ba /* U1 -- Output rate of the NMEA-GX-GGA message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GGA_SPI 0x209100be /* U1 -- Output rate of the NMEA-GX-GGA message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GGA_UART1 0x209100bb /* U1 -- Output rate of the NMEA-GX-GGA message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GLL_I2C 0x209100c9 /* U1 -- Output rate of the NMEA-GX-GLL message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GLL_SPI 0x209100cd /* U1 -- Output rate of the NMEA-GX-GLL message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GLL_UART1 0x209100ca /* U1 -- Output rate of the NMEA-GX-GLL message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GNS_I2C 0x209100b5 /* U1 -- Output rate of the NMEA-GX-GNS message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GNS_SPI 0x209100b9 /* U1 -- Output rate of the NMEA-GX-GNS message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GNS_UART1 0x209100b6 /* U1 -- Output rate of the NMEA-GX-GNS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GRS_I2C 0x209100ce /* U1 -- Output rate of the NMEA-GX-GRS message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GRS_SPI 0x209100d2 /* U1 -- Output rate of the NMEA-GX-GRS message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GRS_UART1 0x209100cf /* U1 -- Output rate of the NMEA-GX-GRS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GSA_I2C 0x209100bf /* U1 -- Output rate of the NMEA-GX-GSA message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GSA_SPI 0x209100c3 /* U1 -- Output rate of the NMEA-GX-GSA message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GSA_UART1 0x209100c0 /* U1 -- Output rate of the NMEA-GX-GSA message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GST_I2C 0x209100d3 /* U1 -- Output rate of the NMEA-GX-GST message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GST_SPI 0x209100d7 /* U1 -- Output rate of the NMEA-GX-GST message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GST_UART1 0x209100d4 /* U1 -- Output rate of the NMEA-GX-GST message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GSV_I2C 0x209100c4 /* U1 -- Output rate of the NMEA-GX-GSV message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GSV_SPI 0x209100c8 /* U1 -- Output rate of the NMEA-GX-GSV message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_GSV_UART1 0x209100c5 /* U1 -- Output rate of the NMEA-GX-GSV message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_RLM_I2C 0x20910400 /* U1 -- Output rate of the NMEA-GX-RLM message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_RLM_SPI 0x20910404 /* U1 -- Output rate of the NMEA-GX-RLM message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_RLM_UART1 0x20910401 /* U1 -- Output rate of the NMEA-GX-RLM message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_RMC_I2C 0x209100ab /* U1 -- Output rate of the NMEA-GX-RMC message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_RMC_SPI 0x209100af /* U1 -- Output rate of the NMEA-GX-RMC message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_RMC_UART1 0x209100ac /* U1 -- Output rate of the NMEA-GX-RMC message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_VLW_I2C 0x209100e7 /* U1 -- Output rate of the NMEA-GX-VLW message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_VLW_SPI 0x209100eb /* U1 -- Output rate of the NMEA-GX-VLW message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_VLW_UART1 0x209100e8 /* U1 -- Output rate of the NMEA-GX-VLW message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_VTG_I2C 0x209100b0 /* U1 -- Output rate of the NMEA-GX-VTG message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_VTG_SPI 0x209100b4 /* U1 -- Output rate of the NMEA-GX-VTG message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_VTG_UART1 0x209100b1 /* U1 -- Output rate of the NMEA-GX-VTG message on port UART1 */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_ZDA_I2C 0x209100d8 /* U1 -- Output rate of the NMEA-GX-ZDA message on port I2C */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_ZDA_SPI 0x209100dc /* U1 -- Output rate of the NMEA-GX-ZDA message on port SPI */
+#define UBLOX_CFG_MSGOUT_NMEA_ID_ZDA_UART1 0x209100d9 /* U1 -- Output rate of the NMEA-GX-ZDA message on port UART1 */
+#define UBLOX_CFG_MSGOUT_PUBX_ID_POLYP_I2C 0x209100ec /* U1 -- Output rate of the NMEA-GX-PUBX00 message on port I2C */
+#define UBLOX_CFG_MSGOUT_PUBX_ID_POLYP_SPI 0x209100f0 /* U1 -- Output rate of the NMEA-GX-PUBX00 message on port SPI */
+#define UBLOX_CFG_MSGOUT_PUBX_ID_POLYP_UART1 0x209100ed /* U1 -- Output rate of the NMEA-GX-PUBX00 message on port UART1 */
+#define UBLOX_CFG_MSGOUT_PUBX_ID_POLYS_I2C 0x209100f1 /* U1 -- Output rate of the NMEA-GX-PUBX03 message on port I2C */
+#define UBLOX_CFG_MSGOUT_PUBX_ID_POLYS_SPI 0x209100f5 /* U1 -- Output rate of the NMEA-GX-PUBX03 message on port SPI */
+#define UBLOX_CFG_MSGOUT_PUBX_ID_POLYS_UART1 0x209100f2 /* U1 -- Output rate of the NMEA-GX-PUBX03 message on port UART1 */
+#define UBLOX_CFG_MSGOUT_PUBX_ID_POLYT_I2C 0x209100f6 /* U1 -- Output rate of the NMEA-GX-PUBX04 message on port I2C */
+#define UBLOX_CFG_MSGOUT_PUBX_ID_POLYT_SPI 0x209100fa /* U1 -- Output rate of the NMEA-GX-PUBX04 message on port SPI */
+#define UBLOX_CFG_MSGOUT_PUBX_ID_POLYT_UART1 0x209100f7 /* U1 -- Output rate of the NMEA-GX-PUBX04 message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_COMMS_I2C 0x2091034f /* U1 -- Output rate of the UBX-MON-COMMS message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_COMMS_SPI 0x20910353 /* U1 -- Output rate of the UBX-MON-COMMS message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_COMMS_UART1 0x20910350 /* U1 -- Output rate of the UBX-MON-COMMS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_HW2_I2C 0x209101b9 /* U1 -- Output rate of the UBX-MON-HW2 message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_HW2_SPI 0x209101bd /* U1 -- Output rate of the UBX-MON-HW2 message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_HW2_UART1 0x209101ba /* U1 -- Output rate of the UBX-MON-HW2 message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_HW3_I2C 0x20910354 /* U1 -- Output rate of the UBX-MON-HW3 message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_HW3_SPI 0x20910358 /* U1 -- Output rate of the UBX-MON-HW3 message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_HW3_UART1 0x20910355 /* U1 -- Output rate of the UBX-MON-HW3 message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_HW_I2C 0x209101b4 /* U1 -- Output rate of the UBX-MON-HW message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_HW_SPI 0x209101b8 /* U1 -- Output rate of the UBX-MON-HW message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_HW_UART1 0x209101b5 /* U1 -- Output rate of the UBX-MON-HW message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_IO_I2C 0x209101a5 /* U1 -- Output rate of the UBX-MON-IO message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_IO_SPI 0x209101a9 /* U1 -- Output rate of the UBX-MON-IO message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_IO_UART1 0x209101a6 /* U1 -- Output rate of the UBX-MON-IO message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_MSGPP_I2C 0x20910196 /* U1 -- Output rate of the UBX-MON-MSGPP message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_MSGPP_SPI 0x2091019a /* U1 -- Output rate of the UBX-MON-MSGPP message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_MSGPP_UART1 0x20910197 /* U1 -- Output rate of the UBX-MON-MSGPP message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_RF_I2C 0x20910359 /* U1 -- Output rate of the UBX-MON-RF message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_RF_SPI 0x2091035d /* U1 -- Output rate of the UBX-MON-RF message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_RF_UART1 0x2091035a /* U1 -- Output rate of the UBX-MON-RF message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_RXBUF_I2C 0x209101a0 /* U1 -- Output rate of the UBX-MON-RXBUF message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_RXBUF_SPI 0x209101a4 /* U1 -- Output rate of the UBX-MON-RXBUF message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_RXBUF_UART1 0x209101a1 /* U1 -- Output rate of the UBX-MON-RXBUF message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_RXR_I2C 0x20910187 /* U1 -- Output rate of the UBX-MON-RXR message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_RXR_SPI 0x2091018b /* U1 -- Output rate of the UBX-MON-RXR message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_RXR_UART1 0x20910188 /* U1 -- Output rate of the UBX-MON-RXR message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_SPAN_I2C 0x2091038b /* U1 -- Output rate of the UBX-MON-SPAN message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_SPAN_SPI 0x2091038f /* U1 -- Output rate of the UBX-MON-SPAN message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_SPAN_UART1 0x2091038c /* U1 -- Output rate of the UBX-MON-SPAN message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_MON_TXBUF_I2C 0x2091019b /* U1 -- Output rate of the UBX-MON-TXBUF message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_MON_TXBUF_SPI 0x2091019f /* U1 -- Output rate of the UBX-MON-TXBUF message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_MON_TXBUF_UART1 0x2091019c /* U1 -- Output rate of the UBX-MON-TXBUF message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_AOPSTATUS_I2C 0x20910079 /* U1 -- Output rate of the UBX-NAV-AOPSTATUS message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_AOPSTATUS_SPI 0x2091007d /* U1 -- Output rate of the UBX-NAV-AOPSTATUS message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_AOPSTATUS_UART1 0x2091007a /* U1 -- Output rate of the UBX-NAV-AOPSTATUS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_CLOCK_I2C 0x20910065 /* U1 -- Output rate of the UBX-NAV-CLOCK message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_CLOCK_SPI 0x20910069 /* U1 -- Output rate of the UBX-NAV-CLOCK message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_CLOCK_UART1 0x20910066 /* U1 -- Output rate of the UBX-NAV-CLOCK message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_COV_I2C 0x20910083 /* U1 -- Output rate of the UBX-NAV-COV message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_COV_SPI 0x20910087 /* U1 -- Output rate of the UBX-NAV-COV message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_COV_UART1 0x20910084 /* U1 -- Output rate of the UBX-NAV-COV message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_DOP_I2C 0x20910038 /* U1 -- Output rate of the UBX-NAV-DOP message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_DOP_SPI 0x2091003c /* U1 -- Output rate of the UBX-NAV-DOP message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_DOP_UART1 0x20910039 /* U1 -- Output rate of the UBX-NAV-DOP message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_EELL_I2C 0x20910313 /* U1 -- Output rate of the UBX-NAV-EELL message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_EELL_SPI 0x20910317 /* U1 -- Output rate of the UBX-NAV-EELL message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_EELL_UART1 0x20910314 /* U1 -- Output rate of the UBX-NAV-EELL message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_EOE_I2C 0x2091015f /* U1 -- Output rate of the UBX-NAV-EOE message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_EOE_SPI 0x20910163 /* U1 -- Output rate of the UBX-NAV-EOE message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_EOE_UART1 0x20910160 /* U1 -- Output rate of the UBX-NAV-EOE message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_ODO_I2C 0x2091007e /* U1 -- Output rate of the UBX-NAV-ODO message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_ODO_SPI 0x20910082 /* U1 -- Output rate of the UBX-NAV-ODO message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_ODO_UART1 0x2091007f /* U1 -- Output rate of the UBX-NAV-ODO message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_ORB_I2C 0x20910010 /* U1 -- Output rate of the UBX-NAV-ORB message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_ORB_SPI 0x20910014 /* U1 -- Output rate of the UBX-NAV-ORB message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_ORB_UART1 0x20910011 /* U1 -- Output rate of the UBX-NAV-ORB message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_POSECEF_I2C 0x20910024 /* U1 -- Output rate of the UBX-NAV-POSECEF message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_POSECEF_SPI 0x20910028 /* U1 -- Output rate of the UBX-NAV-POSECEF message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_POSECEF_UART1 0x20910025 /* U1 -- Output rate of the UBX-NAV-POSECEF message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_POSLLH_I2C 0x20910029 /* U1 -- Output rate of the UBX-NAV-POSLLH message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_POSLLH_SPI 0x2091002d /* U1 -- Output rate of the UBX-NAV-POSLLH message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_POSLLH_UART1 0x2091002a /* U1 -- Output rate of the UBX-NAV-POSLLH message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_PVT_I2C 0x20910006 /* U1 -- Output rate of the UBX-NAV-PVT message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_PVT_SPI 0x2091000a /* U1 -- Output rate of the UBX-NAV-PVT message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_PVT_UART1 0x20910007 /* U1 -- Output rate of the UBX-NAV-PVT message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SAT_I2C 0x20910015 /* U1 -- Output rate of the UBX-NAV-SAT message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SAT_SPI 0x20910019 /* U1 -- Output rate of the UBX-NAV-SAT message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SAT_UART1 0x20910016 /* U1 -- Output rate of the UBX-NAV-SAT message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SBAS_I2C 0x2091006a /* U1 -- Output rate of the UBX-NAV-SBAS message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SBAS_SPI 0x2091006e /* U1 -- Output rate of the UBX-NAV-SBAS message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SBAS_UART1 0x2091006b /* U1 -- Output rate of the UBX-NAV-SBAS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SIG_I2C 0x20910345 /* U1 -- Output rate of the UBX-NAV-SIG message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SIG_SPI 0x20910349 /* U1 -- Output rate of the UBX-NAV-SIG message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SIG_UART1 0x20910346 /* U1 -- Output rate of the UBX-NAV-SIG message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SLAS_I2C 0x20910336 /* U1 -- Output rate of the UBX-NAV-SLAS message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SLAS_SPI 0x2091033a /* U1 -- Output rate of the UBX-NAV-SLAS message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_SLAS_UART1 0x20910337 /* U1 -- Output rate of the UBX-NAV-SLAS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_STATUS_I2C 0x2091001a /* U1 -- Output rate of the UBX-NAV-STATUS message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_STATUS_SPI 0x2091001e /* U1 -- Output rate of the UBX-NAV-STATUS message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_STATUS_UART1 0x2091001b /* U1 -- Output rate of the UBX-NAV-STATUS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEBDS_I2C 0x20910051 /* U1 -- Output rate of the UBX-NAV-TIMEBDS message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEBDS_SPI 0x20910055 /* U1 -- Output rate of the UBX-NAV-TIMEBDS message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEBDS_UART1 0x20910052 /* U1 -- Output rate of the UBX-NAV-TIMEBDS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEGAL_I2C 0x20910056 /* U1 -- Output rate of the UBX-NAV-TIMEGAL message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEGAL_SPI 0x2091005a /* U1 -- Output rate of the UBX-NAV-TIMEGAL message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEGAL_UART1 0x20910057 /* U1 -- Output rate of the UBX-NAV-TIMEGAL message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEGLO_I2C 0x2091004c /* U1 -- Output rate of the UBX-NAV-TIMEGLO message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEGLO_SPI 0x20910050 /* U1 -- Output rate of the UBX-NAV-TIMEGLO message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEGLO_UART1 0x2091004d /* U1 -- Output rate of the UBX-NAV-TIMEGLO message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEGPS_I2C 0x20910047 /* U1 -- Output rate of the UBX-NAV-TIMEGPS message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEGPS_SPI 0x2091004b /* U1 -- Output rate of the UBX-NAV-TIMEGPS message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEGPS_UART1 0x20910048 /* U1 -- Output rate of the UBX-NAV-TIMEGPS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMELS_I2C 0x20910060 /* U1 -- Output rate of the UBX-NAV-TIMELS message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMELS_SPI 0x20910064 /* U1 -- Output rate of the UBX-NAV-TIMELS message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMELS_UART1 0x20910061 /* U1 -- Output rate of the UBX-NAV-TIMELS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEQZSS_I2C 0x20910386 /* U1 -- Output rate of the UBX-NAV-TIMEQZSS message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEQZSS_SPI 0x2091038a /* U1 -- Output rate of the UBX-NAV-TIMEQZSS message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEQZSS_UART1 0x20910387 /* U1 -- Output rate of the UBX-NAV-TIMEQZSS message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEUTC_I2C 0x2091005b /* U1 -- Output rate of the UBX-NAV-TIMEUTC message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEUTC_SPI 0x2091005f /* U1 -- Output rate of the UBX-NAV-TIMEUTC message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_TIMEUTC_UART1 0x2091005c /* U1 -- Output rate of the UBX-NAV-TIMEUTC message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_VELECEF_I2C 0x2091003d /* U1 -- Output rate of the UBX-NAV-VELECEF message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_VELECEF_SPI 0x20910041 /* U1 -- Output rate of the UBX-NAV-VELECEF message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_VELECEF_UART1 0x2091003e /* U1 -- Output rate of the UBX-NAV-VELECEF message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_VELNED_I2C 0x20910042 /* U1 -- Output rate of the UBX-NAV-VELNED message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_VELNED_SPI 0x20910046 /* U1 -- Output rate of the UBX-NAV-VELNED message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_NAV_VELNED_UART1 0x20910043 /* U1 -- Output rate of the UBX-NAV-VELNED message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_MEASX_I2C 0x20910204 /* U1 -- Output rate of the UBX-RXM-MEASX message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_MEASX_SPI 0x20910208 /* U1 -- Output rate of the UBX-RXM-MEASX message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_MEASX_UART1 0x20910205 /* U1 -- Output rate of the UBX-RXM-MEASX message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_RAWX_I2C 0x209102a4 /* U1 -- Output rate of the UBX-RXM-RAWX message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_RAWX_SPI 0x209102a8 /* U1 -- Output rate of the UBX-RXM-RAWX message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_RAWX_UART1 0x209102a5 /* U1 -- Output rate of the UBX-RXM-RAWX message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_RLM_I2C 0x2091025e /* U1 -- Output rate of the UBX-RXM-RLM message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_RLM_SPI 0x20910262 /* U1 -- Output rate of the UBX-RXM-RLM message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_RLM_UART1 0x2091025f /* U1 -- Output rate of the UBX-RXM-RLM message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_SFRBX_I2C 0x20910231 /* U1 -- Output rate of the UBX-RXM-SFRBX message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_SFRBX_SPI 0x20910235 /* U1 -- Output rate of the UBX-RXM-SFRBX message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_RXM_SFRBX_UART1 0x20910232 /* U1 -- Output rate of the UBX-RXM-SFRBX message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_TIM_TM2_I2C 0x20910178 /* U1 -- Output rate of the UBX-TIM-TM2 message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_TIM_TM2_SPI 0x2091017c /* U1 -- Output rate of the UBX-TIM-TM2 message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_TIM_TM2_UART1 0x20910179 /* U1 -- Output rate of the UBX-TIM-TM2 message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_TIM_TP_I2C 0x2091017d /* U1 -- Output rate of the UBX-TIM-TP message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_TIM_TP_SPI 0x20910181 /* U1 -- Output rate of the UBX-TIM-TP message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_TIM_TP_UART1 0x2091017e /* U1 -- Output rate of the UBX-TIM-TP message on port UART1 */
+#define UBLOX_CFG_MSGOUT_UBX_TIM_VRFY_I2C 0x20910092 /* U1 -- Output rate of the UBX-TIM-VRFY message on port I2C */
+#define UBLOX_CFG_MSGOUT_UBX_TIM_VRFY_SPI 0x20910096 /* U1 -- Output rate of the UBX-TIM-VRFY message on port SPI */
+#define UBLOX_CFG_MSGOUT_UBX_TIM_VRFY_UART1 0x20910093 /* U1 -- Output rate of the UBX-TIM-VRFY message on port UART1 */
+
#endif /* _AO_GPS_UBLOX_H_ */
#else
printf ("Alt: %d\n", AO_TELEMETRY_LOCATION_ALTITUDE(&ao_gps_data));
#endif
+ printf ("Pdop/Hdop/Vdop: %u %u %u\n", ao_gps_data.pdop, ao_gps_data.hdop, ao_gps_data.vdop);
+ printf ("Ground Speed/Climb Rate/Course: %u %d %u\n", ao_gps_data.ground_speed,
+ ao_gps_data.climb_rate, ao_gps_data.course);
printf ("Flags: 0x%x\n", ao_gps_data.flags);
printf ("Sats: %d", ao_gps_tracking_data.channels);
for (i = 0; i < ao_gps_tracking_data.channels; i++)
/* Get any existing flight number */
ao_flight_number = ao_log_max_flight();
+ ao_storage_setup();
+
#if FLIGHT_LOG_APPEND
/* Deal with older OS versions which stored multiple
TOPDIR=..
endif
+ifdef RAMSIZE
+LINKER_SCRIPT=altos-$(RAMSIZE).ld
+else
+LINKER_SCRIPT=altos.ld
+endif
+
include $(TOPDIR)/lpc/Makefile-lpc.defs
-LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/lpc -Taltos.ld -n
+LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/lpc -T$(LINKER_SCRIPT) -n
ao_serial_lpc.h: $(TOPDIR)/lpc/baud_rate ao_pins.h
nickle $(TOPDIR)/lpc/baud_rate `awk '/AO_LPC_CLKOUT/{print $$3}' ao_pins.h` > $@
--- /dev/null
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+__flash = 0x1000;
+__flash_size = 28K;
+__ram = 0x10000000;
+__ram_size = 6k;
+__stack_size = 128;
+
+INCLUDE registers.ld
+INCLUDE picolibc.ld
#
#
+RAMSIZE=6k
+
include ../lpc/Makefile.defs
INC = \
ao_task.h \
ao_whiten.h \
ao_cc115l.h \
+ ao_gps_ublox.h \
ao_fec.h \
lpc.h \
Makefile
#define LED_0_PIN 25
#define AO_LED_GREEN (1 << 0)
#define AO_LED_PANIC AO_LED_GREEN
+#define AO_LED_GPS_LOCK AO_LED_GREEN
/* Radio */
#define HAS_SPI_0 1
*/
#define AO_SERIAL_SPEED_UBLOX AO_SERIAL_SPEED_9600
+#define AO_UBLOX_VERSION 10
/*
* Radio (cc1200)
{
ao_clock_init();
+ ao_led_init();
+
ao_task_init();
ao_timer_init();
set_radio_enable_tool_tip();
row++;
+ /* Report feet */
+ c = new GridBagConstraints();
+ c.gridx = 0; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ c.ipady = 5;
+ report_feet_label = new JLabel("Beep max height in:");
+ pane.add(report_feet_label, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 4; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ c.ipady = 5;
+ report_feet_value = new JComboBox<String>(report_feet_values);
+ report_feet_value.setEditable(false);
+ report_feet_value.addItemListener(this);
+ pane.add(report_feet_value, c);
+ set_report_feet_tool_tip();
+ row++;
+
/* Radio 10mW limit */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = row;