From ffade307317ee9ff85fc9ec1b8253564f217bfa9 Mon Sep 17 00:00:00 2001 From: Michael Tatarinov Date: Tue, 23 Oct 2012 10:07:32 +0400 Subject: Mapping NMEA-ID (33..64) to SBAS PRN and minor refactoring. This change required a regression-test rebuild. Signed-off-by: Eric S. Raymond --- driver_geostar.c | 6 +++--- driver_nmea0183.c | 8 ++++++++ driver_sirf.c | 2 +- gps.h | 20 +++++++++++++------- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/driver_geostar.c b/driver_geostar.c index 7f6a5c09..88cd7e6e 100644 --- a/driver_geostar.c +++ b/driver_geostar.c @@ -28,9 +28,9 @@ static int decode_channel_id (uint32_t ch_id) { int num = 0; - num = (int)(ch_id & 0x1F); /* SV ID */ - if((ch_id & (1<<30)) == 0) num += 64; /* GLONASS SV */ - else if (num == 0 ) num = 32; /* GPS SV */ + num = (int)(ch_id & 0x1F); /* SV ID */ + if((ch_id & (1<<30)) == 0) num += GLONASS_PRN_MAP; /* GLONASS SV */ + else if (num == 0 ) num = 32; /* GPS SV */ return num; } diff --git a/driver_nmea0183.c b/driver_nmea0183.c index 65b6fe14..828f1b2d 100644 --- a/driver_nmea0183.c +++ b/driver_nmea0183.c @@ -571,6 +571,14 @@ static gps_mask_t processGPGSV(int count, char *field[], } session->gpsdata.PRN[session->gpsdata.satellites_visible] = atoi(field[fldnum++]); + /* + * NMEA-ID (33..64) to SBAS PRN. + * Check SBAS_PRN(NMEA-ID) is required because some GPSes sends RPN instead of NMEA-ID. + */ + if (session->gpsdata.PRN[session->gpsdata.satellites_visible] >= 33 + && session->gpsdata.PRN[session->gpsdata.satellites_visible] <= 64 + && !SBAS_PRN(session->gpsdata.PRN[session->gpsdata.satellites_visible])) + session->gpsdata.PRN[session->gpsdata.satellites_visible] += 87; session->gpsdata.elevation[session->gpsdata.satellites_visible] = atoi(field[fldnum++]); session->gpsdata.azimuth[session->gpsdata.satellites_visible] = diff --git a/driver_sirf.c b/driver_sirf.c index 93f9443a..ce07052a 100644 --- a/driver_sirf.c +++ b/driver_sirf.c @@ -580,7 +580,7 @@ static gps_mask_t sirf_msg_svinfo(struct gps_device_t *session, /* mark SBAS sats in use if SBAS was in use as of the last MID 27 */ for (i = 0; i < st; i++) { int prn = session->gpsdata.PRN[i]; - if (DGPS_PRN(prn) \ + if (SBAS_PRN(prn) \ && session->gpsdata.status == STATUS_DGPS_FIX \ && session->driver.sirf.dgps_source == SIRF_DGPS_SOURCE_SBAS) session->gpsdata.used[session->gpsdata.satellites_used++] = prn; diff --git a/gps.h b/gps.h index aaceaca3..5d69154a 100644 --- a/gps.h +++ b/gps.h @@ -98,14 +98,20 @@ struct gps_fix_t { /* * Satellite ID classes. - * U.S. GPS authorities reserve PRNs 1-64 for GPS satellites. - * GLONASS birds reuse GPS PRNs; it is a GPSD convention to map them to - * IDs 64 and above (some other programs push them to 33 and above). - * All SBAS/WAAS/EGNOS birds have PRNs above 100. + * IS-GPS-200 Revision E, paragraph 6.3.6 */ -#define GNSS_PRN(n) (((n) >= 1) && ((n) <= 63)) /* GNSS satellite */ -#define GLONASS_PRN(n) (((n) >= 64) && ((n) <= 96)) /* GLONASS satellite */ -#define DGPS_PRN(n) ((n) >= 100) +#define GPS_PRN(n) (((n) >= 1) && ((n) <= 63)) /* U.S. GPS satellite */ +#define GBAS_PRN(n) ((n) >= 64 && ((n) <= 119)) /* Ground Based Augmentation System and other augmentation systems */ +#define SBAS_PRN(n) ((n) >= 120 && ((n) <= 158)) /* Satellite Based Augmentation System */ +#define GNSS_PRN(n) ((n) >= 159 && ((n) <= 210)) /* other Global Navigation Satellite System */ + +/* + * GLONASS birds reuse GPS PRNs. + * it is a GPSD convention to map them to IDs 65..96. + * (some other programs push them to 33 and above). + */ +#define GLONASS_PRN_MAP 64 +#define GLONASS_PRN(n) (((n) >= 1 + GLONASS_PRN_MAP) && ((n) <= 32 + GLONASS_PRN_MAP) /* GLONASS satellite */ /* * The structure describing the pseudorange errors (GPGST) -- cgit v1.2.1