2011-10-01 18:45:20 +00:00
|
|
|
/*!
|
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
|
|
|
* \file gps_l1_ca_telemetry_decoder_cc.cc
|
2011-12-28 21:36:45 +00:00
|
|
|
* \brief Implementation of a NAV message demodulator block based on
|
|
|
|
* Kay Borre book MATLAB-based GPS receiver
|
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
|
|
|
* \author Javier Arribas, 2011. jarribas(at)cttc.es
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2012-01-10 08:43:58 +00:00
|
|
|
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
|
|
|
* GNSS-SDR 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 3 of the License, or
|
|
|
|
* at your option) any later version.
|
|
|
|
*
|
|
|
|
* GNSS-SDR 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 GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
2011-10-01 18:45:20 +00:00
|
|
|
*/
|
|
|
|
|
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
|
|
|
/*!
|
2011-12-28 03:05:37 +00:00
|
|
|
* \todo Clean this code and move the telemetry definitions to GPS_L1_CA system definitions file
|
2011-10-01 18:45:20 +00:00
|
|
|
*/
|
|
|
|
|
2012-01-03 09:27:24 +00:00
|
|
|
#include "gps_l1_ca_telemetry_decoder_cc.h"
|
2011-10-01 18:45:20 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <bitset>
|
|
|
|
#include <gnuradio/gr_io_signature.h>
|
|
|
|
#include <glog/log_severity.h>
|
|
|
|
#include <glog/logging.h>
|
2011-12-28 03:05:37 +00:00
|
|
|
#include "control_message_factory.h"
|
|
|
|
|
2012-01-16 18:27:31 +00:00
|
|
|
#define _lrotl(X,N) ((X << N) ^ (X >> (32-N))) // Used in the parity check algorithm
|
2011-10-01 18:45:20 +00:00
|
|
|
|
|
|
|
|
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
|
|
|
using google::LogMessage;
|
|
|
|
/*!
|
|
|
|
* \todo name and move the magic numbers to GPS_L1_CA.h
|
|
|
|
*/
|
2011-10-01 18:45:20 +00:00
|
|
|
gps_l1_ca_telemetry_decoder_cc_sptr
|
|
|
|
gps_l1_ca_make_telemetry_decoder_cc(unsigned int satellite, long if_freq, long fs_in, unsigned
|
2012-01-10 08:43:58 +00:00
|
|
|
int vector_length, gr_msg_queue_sptr queue, bool dump)
|
|
|
|
{
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2012-01-10 08:43:58 +00:00
|
|
|
return gps_l1_ca_telemetry_decoder_cc_sptr(new gps_l1_ca_telemetry_decoder_cc(satellite, if_freq,
|
|
|
|
fs_in, vector_length, queue, dump));
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-01-11 09:01:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
void gps_l1_ca_telemetry_decoder_cc::forecast (int noutput_items, gr_vector_int &ninput_items_required)
|
2012-01-10 08:43:58 +00:00
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < 3; i++)
|
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
ninput_items_required[i] = d_samples_per_bit*8; //set the required sample history
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-11 09:01:24 +00:00
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(unsigned int satellite, long if_freq, long fs_in, unsigned
|
2012-01-10 08:43:58 +00:00
|
|
|
int vector_length, gr_msg_queue_sptr queue, bool dump) :
|
|
|
|
gr_block ("gps_navigation_cc", gr_make_io_signature (5, 5, sizeof(double)),
|
|
|
|
gr_make_io_signature(1, 1, sizeof(gnss_synchro)))
|
|
|
|
{
|
|
|
|
// initialize internal vars
|
|
|
|
d_queue = queue;
|
|
|
|
d_dump = dump;
|
|
|
|
d_satellite = satellite;
|
|
|
|
d_vector_length = vector_length;
|
2012-01-16 18:27:31 +00:00
|
|
|
d_samples_per_bit = ( GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS ) / GPS_CA_TELEMETRY_RATE_BITS_SECOND;
|
2012-01-11 09:01:24 +00:00
|
|
|
d_fs_in = fs_in;
|
2012-01-16 18:27:31 +00:00
|
|
|
d_preamble_duration_seconds = (1.0 / GPS_CA_TELEMETRY_RATE_BITS_SECOND) * GPS_CA_PREAMBLE_LENGTH_BITS;
|
2012-01-10 08:43:58 +00:00
|
|
|
//std::cout<<"d_preamble_duration_seconds="<<d_preamble_duration_seconds<<"\r\n";
|
|
|
|
// set the preamble
|
2012-01-16 18:27:31 +00:00
|
|
|
unsigned short int preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE;
|
2012-01-10 08:43:58 +00:00
|
|
|
|
2012-01-16 18:27:31 +00:00
|
|
|
memcpy((unsigned short int*)this->d_preambles_bits, (unsigned short int*)preambles_bits, GPS_CA_PREAMBLE_LENGTH_BITS*sizeof(unsigned short int));
|
2012-01-10 08:43:58 +00:00
|
|
|
|
|
|
|
// preamble bits to sampled symbols
|
2012-01-16 18:27:31 +00:00
|
|
|
d_preambles_symbols = (signed int*)malloc(sizeof(signed int) * GPS_CA_PREAMBLE_LENGTH_BITS * d_samples_per_bit);
|
2012-01-11 09:01:24 +00:00
|
|
|
int n = 0;
|
2012-01-16 18:27:31 +00:00
|
|
|
for (int i=0; i<GPS_CA_PREAMBLE_LENGTH_BITS; i++)
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
for (unsigned int j=0; j<d_samples_per_bit; j++)
|
2012-01-10 08:43:58 +00:00
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
if (d_preambles_bits[i] == 1)
|
2012-01-10 08:43:58 +00:00
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
d_preambles_symbols[n] = 1;
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
d_preambles_symbols[n] = -1;
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
|
|
|
n++;
|
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
2012-01-11 09:01:24 +00:00
|
|
|
d_sample_counter = 0;
|
|
|
|
d_preamble_code_phase_seconds = 0;
|
|
|
|
d_stat = 0;
|
|
|
|
d_preamble_index = 0;
|
|
|
|
d_symbol_accumulator_counter = 0;
|
|
|
|
d_frame_bit_index = 0;
|
|
|
|
|
|
|
|
d_flag_frame_sync = false;
|
|
|
|
d_GPS_frame_4bytes = 0;
|
|
|
|
d_prev_GPS_frame_4bytes = 0;
|
|
|
|
d_flag_parity = false;
|
2012-01-10 08:43:58 +00:00
|
|
|
|
|
|
|
//set_history(d_samples_per_bit*8); // At least a history of 8 bits are needed to correlate with the preamble
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-01-11 09:01:24 +00:00
|
|
|
|
2012-01-10 08:43:58 +00:00
|
|
|
gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc()
|
|
|
|
{
|
|
|
|
delete d_preambles_symbols;
|
|
|
|
d_dump_file.close();
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-01-03 09:27:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword)
|
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
unsigned int d1, d2, d3, d4, d5, d6, d7, t, parity;
|
2012-01-03 09:27:24 +00:00
|
|
|
|
2012-01-10 08:43:58 +00:00
|
|
|
/* XOR as many bits in parallel as possible. The magic constants pick
|
2012-01-03 09:27:24 +00:00
|
|
|
up bits which are to be XOR'ed together to implement the GPS parity
|
|
|
|
check algorithm described in IS-GPS-200E. This avoids lengthy shift-
|
|
|
|
and-xor loops. */
|
|
|
|
|
2012-01-10 08:43:58 +00:00
|
|
|
d1 = gpsword & 0xFBFFBF00;
|
|
|
|
d2 = _lrotl(gpsword,1) & 0x07FFBF01;
|
|
|
|
d3 = _lrotl(gpsword,2) & 0xFC0F8100;
|
|
|
|
d4 = _lrotl(gpsword,3) & 0xF81FFE02;
|
|
|
|
d5 = _lrotl(gpsword,4) & 0xFC00000E;
|
|
|
|
d6 = _lrotl(gpsword,5) & 0x07F00001;
|
|
|
|
d7 = _lrotl(gpsword,6) & 0x00003000;
|
2012-01-03 09:27:24 +00:00
|
|
|
|
2012-01-10 08:43:58 +00:00
|
|
|
t = d1 ^ d2 ^ d3 ^ d4 ^ d5 ^ d6 ^ d7;
|
2012-01-03 09:27:24 +00:00
|
|
|
|
2012-01-10 08:43:58 +00:00
|
|
|
// Now XOR the 5 6-bit fields together to produce the 6-bit final result.
|
|
|
|
parity = t ^ _lrotl(t,6) ^ _lrotl(t,12) ^ _lrotl(t,18) ^ _lrotl(t,24);
|
|
|
|
parity = parity & 0x3F;
|
2012-01-11 09:01:24 +00:00
|
|
|
if (parity == (gpsword&0x3F)) return(true);
|
|
|
|
else return(false);
|
2012-01-03 09:27:24 +00:00
|
|
|
}
|
|
|
|
|
2012-01-11 09:01:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_int &ninput_items,
|
2012-01-11 09:01:24 +00:00
|
|
|
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
|
|
|
|
{
|
|
|
|
int corr_value = 0;
|
2012-01-10 08:43:58 +00:00
|
|
|
int preamble_diff;
|
|
|
|
|
|
|
|
gnss_synchro gps_synchro; //structure to save the synchronization information
|
|
|
|
gnss_synchro **out = (gnss_synchro **) &output_items[0];
|
|
|
|
d_sample_counter++; //count for the processed samples
|
|
|
|
|
|
|
|
const double **in = (const double **) &input_items[0]; //Get the input samples pointer
|
|
|
|
// ########### Output the tracking data to navigation and PVT ##########
|
|
|
|
// Output channel 0: Prompt correlator output Q
|
|
|
|
// *out[0]=(double)d_Prompt.real();
|
|
|
|
// // Output channel 1: Prompt correlator output I
|
|
|
|
// *out[1]=(double)d_Prompt.imag();
|
|
|
|
// // Output channel 2: PRN absolute delay [s]
|
|
|
|
// *out[2]=d_sample_counter_seconds;
|
|
|
|
// // Output channel 3: d_acc_carrier_phase_rad [rad]
|
|
|
|
// *out[3]=(double)d_acc_carrier_phase_rad;
|
|
|
|
// // Output channel 4: PRN code phase [s]
|
|
|
|
// *out[4]=(double)d_code_phase_samples*(1/(float)d_fs_in);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \todo Check the HOW GPS time computation, taking into account that the preamble correlation last 160 symbols, which is 160 ms in GPS CA L1
|
|
|
|
*/
|
|
|
|
// FIFO history to get the exact timestamp of the first symbol of the preamble
|
|
|
|
// if (d_prn_start_sample_history.size()<160)
|
|
|
|
// {
|
|
|
|
// // fill the queue
|
|
|
|
// d_prn_start_sample_history.push_front(in[2][0]);
|
|
|
|
// consume_each(1); //one by one
|
|
|
|
// return 1;
|
|
|
|
// }else{
|
|
|
|
// d_prn_start_sample_history.pop_back();
|
|
|
|
// d_prn_start_sample_history.push_front(in[2][0]);
|
|
|
|
// }
|
|
|
|
// TODO Optimize me!
|
|
|
|
//******* preamble correlation ********
|
2012-01-11 09:01:24 +00:00
|
|
|
for (unsigned int i=0; i<d_samples_per_bit*8; i++)
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2012-01-10 08:43:58 +00:00
|
|
|
if (in[1][i] < 0) // symbols clipping
|
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
corr_value -= d_preambles_symbols[i];
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
corr_value += d_preambles_symbols[i];
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
2012-01-10 08:43:58 +00:00
|
|
|
d_flag_preamble=false;
|
|
|
|
//******* frame sync ******************
|
|
|
|
if (abs(corr_value)>=160)
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2012-01-10 08:43:58 +00:00
|
|
|
//TODO: Rewrite with state machine
|
2012-01-11 09:01:24 +00:00
|
|
|
if (d_stat == 0)
|
2012-01-10 08:43:58 +00:00
|
|
|
{
|
|
|
|
d_GPS_FSM.Event_gps_word_preamble();
|
2012-01-11 09:01:24 +00:00
|
|
|
d_preamble_index = d_sample_counter;//record the preamble sample stamp
|
2012-01-16 18:27:31 +00:00
|
|
|
std::cout << "Preamble detection for SAT " << d_satellite << std::endl;
|
2012-01-11 09:01:24 +00:00
|
|
|
d_symbol_accumulator = 0; //sync the symbol to bits integrator
|
|
|
|
d_symbol_accumulator_counter = 0;
|
|
|
|
d_frame_bit_index = 8;
|
|
|
|
d_stat = 1; // enter into frame pre-detection status
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
2012-01-11 09:01:24 +00:00
|
|
|
else if (d_stat == 1) //check 6 seconds of preample separation
|
2012-01-10 08:43:58 +00:00
|
|
|
{
|
2012-01-16 18:27:31 +00:00
|
|
|
preamble_diff = abs(d_sample_counter - d_preamble_index);
|
2012-01-11 09:01:24 +00:00
|
|
|
if (abs(preamble_diff - 6000) < 1)
|
2012-01-10 08:43:58 +00:00
|
|
|
{
|
|
|
|
d_GPS_FSM.Event_gps_word_preamble();
|
2012-01-11 09:01:24 +00:00
|
|
|
d_flag_preamble = true;
|
2012-01-16 18:27:31 +00:00
|
|
|
d_preamble_index = d_sample_counter; //record the preamble sample stamp (t_P)
|
2012-01-11 09:01:24 +00:00
|
|
|
d_preamble_time_seconds = in[2][0] - d_preamble_duration_seconds; //record the PRN start sample index associated to the preamble
|
|
|
|
d_preamble_code_phase_seconds = in[4][0];
|
2012-01-10 08:43:58 +00:00
|
|
|
|
|
|
|
if (!d_flag_frame_sync)
|
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
d_flag_frame_sync = true;
|
|
|
|
std::cout <<" Frame sync SAT " << d_satellite << " with preamble start at " << d_preamble_time_seconds << " [s]" << std::endl;
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
2012-01-10 08:43:58 +00:00
|
|
|
else
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
if (d_stat == 1)
|
2012-01-10 08:43:58 +00:00
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
preamble_diff = d_sample_counter - d_preamble_index;
|
|
|
|
if (preamble_diff > 6001)
|
2012-01-10 08:43:58 +00:00
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
std::cout << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff << std::endl;
|
|
|
|
d_stat = 0; //lost of frame sync
|
|
|
|
d_flag_frame_sync = false;
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
2012-01-10 08:43:58 +00:00
|
|
|
|
|
|
|
//******* code error accumulator *****
|
|
|
|
//d_preamble_phase-=in[3][0];
|
|
|
|
//******* SYMBOL TO BIT *******
|
|
|
|
|
2012-01-11 09:01:24 +00:00
|
|
|
d_symbol_accumulator += in[1][d_samples_per_bit*8 - 1]; // accumulate the input value in d_symbol_accumulator
|
2012-01-10 08:43:58 +00:00
|
|
|
d_symbol_accumulator_counter++;
|
2012-01-11 09:01:24 +00:00
|
|
|
if (d_symbol_accumulator_counter == 20)
|
2012-01-10 08:43:58 +00:00
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
if (d_symbol_accumulator > 0)
|
2012-01-10 08:43:58 +00:00
|
|
|
{ //symbol to bit
|
2012-01-11 09:01:24 +00:00
|
|
|
d_GPS_frame_4bytes +=1; //insert the telemetry bit in LSB
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
2012-01-11 09:01:24 +00:00
|
|
|
d_symbol_accumulator = 0;
|
|
|
|
d_symbol_accumulator_counter = 0;
|
2012-01-10 08:43:58 +00:00
|
|
|
|
|
|
|
//******* bits to words ******
|
|
|
|
d_frame_bit_index++;
|
2012-01-11 09:01:24 +00:00
|
|
|
if (d_frame_bit_index == 30)
|
2012-01-10 08:43:58 +00:00
|
|
|
{
|
2012-01-11 09:01:24 +00:00
|
|
|
d_frame_bit_index = 0;
|
2012-01-10 08:43:58 +00:00
|
|
|
//parity check
|
|
|
|
//Each word in wordbuff is composed of:
|
|
|
|
// Bits 0 to 29 = the GPS data word
|
|
|
|
// Bits 30 to 31 = 2 LSBs of the GPS word ahead.
|
|
|
|
// prepare the extended frame [-2 -1 0 ... 30]
|
|
|
|
if (d_prev_GPS_frame_4bytes & 0x00000001)
|
|
|
|
{
|
2012-01-16 18:27:31 +00:00
|
|
|
d_GPS_frame_4bytes = d_GPS_frame_4bytes | 0x40000000;
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
|
|
|
if (d_prev_GPS_frame_4bytes & 0x00000002)
|
|
|
|
{
|
2012-01-16 18:27:31 +00:00
|
|
|
d_GPS_frame_4bytes = d_GPS_frame_4bytes | 0x80000000;
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
|
|
|
/* Check that the 2 most recently logged words pass parity. Have to first
|
|
|
|
invert the data bits according to bit 30 of the previous word. */
|
|
|
|
if(d_GPS_frame_4bytes & 0x40000000)
|
|
|
|
{
|
|
|
|
d_GPS_frame_4bytes ^= 0x3FFFFFC0; // invert the data bits (using XOR)
|
|
|
|
}
|
|
|
|
if (gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(d_GPS_frame_4bytes))
|
|
|
|
{
|
2012-01-16 18:27:31 +00:00
|
|
|
memcpy(&d_GPS_FSM.d_GPS_frame_4bytes, &d_GPS_frame_4bytes, sizeof(char)*4);
|
2012-01-11 09:01:24 +00:00
|
|
|
d_GPS_FSM.d_preamble_time_ms = d_preamble_time_seconds*1000.0;
|
2012-01-10 08:43:58 +00:00
|
|
|
d_GPS_FSM.Event_gps_word_valid();
|
2012-01-11 09:01:24 +00:00
|
|
|
d_flag_parity = true;
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d_GPS_FSM.Event_gps_word_invalid();
|
2012-01-11 09:01:24 +00:00
|
|
|
d_flag_parity = false;
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
2012-01-11 09:01:24 +00:00
|
|
|
d_prev_GPS_frame_4bytes = d_GPS_frame_4bytes; // save the actual frame
|
|
|
|
d_GPS_frame_4bytes = d_GPS_frame_4bytes & 0;
|
2012-01-10 08:43:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d_GPS_frame_4bytes<<=1; //shift 1 bit left the telemetry word
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// output the frame
|
|
|
|
consume_each(1); //one by one
|
|
|
|
|
2012-01-16 18:27:31 +00:00
|
|
|
|
|
|
|
//! \todo This has to be documented and included in the header!!!!
|
2012-01-11 09:01:24 +00:00
|
|
|
gps_synchro.valid_word = (d_flag_frame_sync == true and d_flag_parity == true);
|
|
|
|
gps_synchro.flag_preamble = d_flag_preamble;
|
|
|
|
gps_synchro.preamble_delay_ms = d_preamble_time_seconds*1000.0;
|
|
|
|
gps_synchro.prn_delay_ms = (in[2][0] - d_preamble_duration_seconds)*1000.0;
|
|
|
|
gps_synchro.preamble_code_phase_ms = d_preamble_code_phase_seconds*1000.0;
|
|
|
|
gps_synchro.preamble_code_phase_correction_ms = (in[4][0] - d_preamble_code_phase_seconds)*1000.0;
|
|
|
|
gps_synchro.satellite_PRN = d_satellite;
|
|
|
|
gps_synchro.channel_ID = d_channel;
|
|
|
|
*out[0] = gps_synchro;
|
2012-01-10 08:43:58 +00:00
|
|
|
return 1;
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-10 08:43:58 +00:00
|
|
|
void gps_l1_ca_telemetry_decoder_cc::set_satellite(int satellite)
|
|
|
|
{
|
|
|
|
d_satellite = satellite;
|
2012-01-11 09:01:24 +00:00
|
|
|
d_GPS_FSM.i_satellite_PRN = satellite;
|
2012-01-10 08:43:58 +00:00
|
|
|
LOG_AT_LEVEL(INFO) << "Navigation Satellite set to " << d_satellite;
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-01-10 08:43:58 +00:00
|
|
|
void gps_l1_ca_telemetry_decoder_cc::set_channel(int channel)
|
|
|
|
{
|
|
|
|
d_channel = channel;
|
2012-01-11 09:01:24 +00:00
|
|
|
d_GPS_FSM.i_channel_ID = channel;
|
2012-01-10 08:43:58 +00:00
|
|
|
LOG_AT_LEVEL(INFO) << "Navigation channel set to " << channel;
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|