From 09ea6f1b1f8a4abb6d6c559f220835befe861f6d Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Fri, 16 Mar 2012 12:05:01 +0100 Subject: [PATCH] gps subsystem: really need to define GPS_FIX_x in gps.h and convert all implementations to the same fix mask airborne it would work, but GCS, etc. of course rely on 0->nofix 3->3d-fix in the messages --- sw/airborne/subsystems/gps.h | 4 ++++ sw/airborne/subsystems/gps/gps_mtk.c | 11 ++++++++++- sw/airborne/subsystems/gps/gps_mtk.h | 8 ++++---- sw/airborne/subsystems/gps/gps_nmea.h | 8 ++------ sw/airborne/subsystems/gps/gps_sim.h | 4 ---- sw/airborne/subsystems/gps/gps_sim_nps.h | 4 ---- sw/airborne/subsystems/gps/gps_skytraq.c | 20 ++++++++++++++++++-- sw/airborne/subsystems/gps/gps_skytraq.h | 7 ------- sw/airborne/subsystems/gps/gps_ubx.h | 4 ---- 9 files changed, 38 insertions(+), 32 deletions(-) diff --git a/sw/airborne/subsystems/gps.h b/sw/airborne/subsystems/gps.h index 41728b4a2e..4554855932 100644 --- a/sw/airborne/subsystems/gps.h +++ b/sw/airborne/subsystems/gps.h @@ -37,6 +37,10 @@ #include GPS_TYPE_H #endif +#define GPS_FIX_NONE 0x00 +#define GPS_FIX_2D 0x02 +#define GPS_FIX_3D 0x03 + #define GpsFixValid() (gps.fix == GPS_FIX_3D) diff --git a/sw/airborne/subsystems/gps/gps_mtk.c b/sw/airborne/subsystems/gps/gps_mtk.c index 8aa91650c1..8aeb5da409 100644 --- a/sw/airborne/subsystems/gps/gps_mtk.c +++ b/sw/airborne/subsystems/gps/gps_mtk.c @@ -158,7 +158,16 @@ void gps_mtk_read_message(void) { gps.speed_3d = gps.gspeed; gps.course = (RadOfDeg(MTK_DIY14_NAV_Heading(gps_mtk.msg_buf)))*10; gps.num_sv = MTK_DIY14_NAV_numSV(gps_mtk.msg_buf); - gps.fix = MTK_DIY14_NAV_GPSfix(gps_mtk.msg_buf); + switch (MTK_DIY14_NAV_GPSfix(gps_mtk.msg_buf)) { + case MTK_DIY_FIX_3D: + gps.fix = GPS_FIX_3D; + break; + case MTK_DIY_FIX_2D: + gps.fix = GPS_FIX_2D; + break; + default: + gps.fix = GPS_FIX_NONE; + } gps.tow = MTK_DIY14_NAV_ITOW(gps_mtk.msg_buf);; // FIXME: with MTK DIY 1.4 you do not receive GPS week gps.week = 0; diff --git a/sw/airborne/subsystems/gps/gps_mtk.h b/sw/airborne/subsystems/gps/gps_mtk.h index b28bdaf365..904e665171 100644 --- a/sw/airborne/subsystems/gps/gps_mtk.h +++ b/sw/airborne/subsystems/gps/gps_mtk.h @@ -28,10 +28,6 @@ /** Includes macros generated from mtk.xml */ #include "mtk_protocol.h" -#define GPS_FIX_NONE 0x01 -#define GPS_FIX_2D 0x02 -#define GPS_FIX_3D 0x03 - #define GPS_MTK_MAX_PAYLOAD 255 struct GpsMtk { @@ -109,6 +105,10 @@ extern bool_t gps_configuring; extern void gps_mtk_read_message(void); extern void gps_mtk_parse(uint8_t c); +#define MTK_DIY_FIX_3D 3 +#define MTK_DIY_FIX_2D 2 +#define MTK_DIY_FIX_NONE 1 + /* * dynamic GPS configuration */ diff --git a/sw/airborne/subsystems/gps/gps_nmea.h b/sw/airborne/subsystems/gps/gps_nmea.h index 16c9706b7d..20f8452d39 100644 --- a/sw/airborne/subsystems/gps/gps_nmea.h +++ b/sw/airborne/subsystems/gps/gps_nmea.h @@ -20,8 +20,8 @@ * */ -/** @file gps_nmea.h - * NMEA protocol specific code +/** \file gps_nmea.h + * \brief NMEA protocol specific code * */ @@ -33,10 +33,6 @@ #define GPS_NB_CHANNELS 16 -#define GPS_FIX_NONE 0x00 -#define GPS_FIX_2D 0x02 -#define GPS_FIX_3D 0x03 - #ifdef DEBUG_NMEA #define NMEA_PRINT(...) { UsbSPrintString( __VA_ARGS__);}; #else diff --git a/sw/airborne/subsystems/gps/gps_sim.h b/sw/airborne/subsystems/gps/gps_sim.h index 3f07b17b9a..4f84766cc5 100644 --- a/sw/airborne/subsystems/gps/gps_sim.h +++ b/sw/airborne/subsystems/gps/gps_sim.h @@ -3,10 +3,6 @@ #include "std.h" -#define GPS_FIX_NONE 0x00 -#define GPS_FIX_2D 0x02 -#define GPS_FIX_3D 0x03 - #define GPS_NB_CHANNELS 16 extern bool_t gps_available; diff --git a/sw/airborne/subsystems/gps/gps_sim_nps.h b/sw/airborne/subsystems/gps/gps_sim_nps.h index b5933b88dd..e1dd5fc05d 100644 --- a/sw/airborne/subsystems/gps/gps_sim_nps.h +++ b/sw/airborne/subsystems/gps/gps_sim_nps.h @@ -3,10 +3,6 @@ #include "nps_sensors.h" -#define GPS_FIX_NONE 0x00 -#define GPS_FIX_2D 0x02 -#define GPS_FIX_3D 0x03 - #define GPS_NB_CHANNELS 16 extern bool_t gps_available; diff --git a/sw/airborne/subsystems/gps/gps_skytraq.c b/sw/airborne/subsystems/gps/gps_skytraq.c index 2f26db61fa..c0730a4eed 100644 --- a/sw/airborne/subsystems/gps/gps_skytraq.c +++ b/sw/airborne/subsystems/gps/gps_skytraq.c @@ -20,6 +20,7 @@ */ #include "subsystems/gps.h" +#include "led.h" #if GPS_USE_LATLONG /* currently needed to get nav_utm_zone0 */ @@ -40,8 +41,12 @@ struct GpsSkytraq gps_skytraq; #define GOT_CHECKSUM 7 #define GOT_SYNC3 8 +#define SKYTRAQ_FIX_NONE 0x00 +#define SKYTRAQ_FIX_2D 0x01 +#define SKYTRAQ_FIX_3D 0x02 +#define SKYTRAQ_FIX_3D_DGPS 0x03 + //#include "my_debug_servo.h" -#include "led.h" void gps_impl_init(void) { @@ -72,9 +77,20 @@ void gps_skytraq_read_message(void) { // sacc; // gps.pdop = SKYTRAQ_NAVIGATION_DATA_PDOP(gps_skytraq.msg_buf); gps.num_sv = SKYTRAQ_NAVIGATION_DATA_NumSV(gps_skytraq.msg_buf); - gps.fix = SKYTRAQ_NAVIGATION_DATA_FixMode(gps_skytraq.msg_buf); gps.tow = SKYTRAQ_NAVIGATION_DATA_TOW(gps_skytraq.msg_buf)/10; + switch (SKYTRAQ_NAVIGATION_DATA_FixMode(gps_skytraq.msg_buf)) { + case SKYTRAQ_FIX_3D_DGPS: + case SKYTRAQ_FIX_3D: + gps.fix = GPS_FIX_3D; + break; + case SKYTRAQ_FIX_2D: + gps.fix = GPS_FIX_2D; + break; + default: + gps.fix = GPS_FIX_NONE; + } + #if GPS_USE_LATLONG /* Computes from (lat, long) in the referenced UTM zone */ struct LlaCoor_f lla_f; diff --git a/sw/airborne/subsystems/gps/gps_skytraq.h b/sw/airborne/subsystems/gps/gps_skytraq.h index 655ce3e4e1..d7c24bbd3a 100644 --- a/sw/airborne/subsystems/gps/gps_skytraq.h +++ b/sw/airborne/subsystems/gps/gps_skytraq.h @@ -24,13 +24,6 @@ #include "mcu_periph/uart.h" - -#define GPS_FIX_NONE 0x00 -#define GPS_FIX_2D 0x01 -#define GPS_FIX_3D 0x02 -#define GPS_FIX_3D_DGPS 0x03 - - #define SKYTRAQ_SYNC1 0xA0 #define SKYTRAQ_SYNC2 0xA1 diff --git a/sw/airborne/subsystems/gps/gps_ubx.h b/sw/airborne/subsystems/gps/gps_ubx.h index 6b811993c4..6929701ec0 100644 --- a/sw/airborne/subsystems/gps/gps_ubx.h +++ b/sw/airborne/subsystems/gps/gps_ubx.h @@ -38,10 +38,6 @@ #define GPS_NB_CHANNELS 16 -#define GPS_FIX_NONE 0x00 -#define GPS_FIX_2D 0x02 -#define GPS_FIX_3D 0x03 - #define GPS_UBX_MAX_PAYLOAD 255 struct GpsUbx { bool_t msg_available;