From ce4ddd03e89d4728cd51301ca8415f8052c337ce Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 3 Jan 2012 09:27:24 +0000 Subject: [PATCH] Deleting gps_telemetry.cc and gps_telemetry.h. Most of the functions were not used anywhere, the others have been moved to places in which make sense. git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@107 64b25241-fba3-4117-9849-534c7e92360d --- .../gps_l1_ca_telemetry_decoder_cc.cc | 38 ++++++- .../gps_l1_ca_telemetry_decoder_cc.h | 14 ++- .../libs/gps_l1_ca_subframe_fsm.h | 1 - src/core/system_parameters/GPS_L1_CA.h | 2 +- .../gps_navigation_message.cc | 12 +++ .../gps_navigation_message.h | 1 + src/core/system_parameters/gps_telemetry.cc | 99 ------------------- src/core/system_parameters/gps_telemetry.h | 42 -------- src/core/system_parameters/jamfile.jam | 1 - src/main/jamfile.jam | 1 - 10 files changed, 58 insertions(+), 153 deletions(-) delete mode 100644 src/core/system_parameters/gps_telemetry.cc delete mode 100644 src/core/system_parameters/gps_telemetry.h diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index c2078a039..a62300117 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -33,16 +33,16 @@ * \todo Clean this code and move the telemetry definitions to GPS_L1_CA system definitions file */ +#include "gps_l1_ca_telemetry_decoder_cc.h" #include #include #include #include #include #include -#include "gps_l1_ca_telemetry_decoder_cc.h" #include "control_message_factory.h" - +#define _lrotl(X,N) ((X << N) ^ (X >> (32-N))) //!< Used in the parity check algorithm using google::LogMessage; @@ -121,6 +121,38 @@ gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc() { } + + +bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword) +{ + unsigned int d1,d2,d3,d4,d5,d6,d7,t,parity; + + /* XOR as many bits in parallel as possible. The magic constants pick + 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. */ + + 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; + + t = d1 ^ d2 ^ d3 ^ d4 ^ d5 ^ d6 ^ d7; + + // 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; + if (parity == (gpsword&0x3F)) + return(true); + else + return(false); + +} + int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { int corr_value=0; @@ -247,7 +279,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i { d_GPS_frame_4bytes ^= 0x3FFFFFC0; // invert the data bits (using XOR) } - if (gps_word_parityCheck(d_GPS_frame_4bytes)) { + if (gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(d_GPS_frame_4bytes)) { memcpy(&d_GPS_FSM.d_GPS_frame_4bytes,&d_GPS_frame_4bytes,sizeof(char)*4); d_GPS_FSM.d_preamble_time_ms=d_preamble_time_seconds*1000.0; d_GPS_FSM.Event_gps_word_valid(); diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h index 765bdd7ce..1f421f67e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h @@ -31,15 +31,17 @@ #ifndef GNSS_SDR_GPS_L1_CA_TELEMETRY_DECODER_CC_H #define GNSS_SDR_GPS_L1_CA_TELEMETRY_DECODER_CC_H + +#include "GPS_L1_CA.h" +#include "gps_l1_ca_subframe_fsm.h" +#include "concurrent_queue.h" #include #include #include -//#include #include -#include "GPS_L1_CA.h" -#include "gps_telemetry.h" -#include "gps_l1_ca_subframe_fsm.h" -#include "concurrent_queue.h" +//#include + + class gps_l1_ca_telemetry_decoder_cc; @@ -64,6 +66,8 @@ private: gps_l1_ca_telemetry_decoder_cc(unsigned int satellite, long if_freq, long fs_in,unsigned int vector_length, gr_msg_queue_sptr queue, bool dump); + bool gps_word_parityCheck(unsigned int gpsword); + // constants unsigned short int d_preambles_bits[8]; diff --git a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h b/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h index 7b18692cf..50c1b6d76 100644 --- a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h +++ b/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.h @@ -45,7 +45,6 @@ #include #include #include "GPS_L1_CA.h" -#include "gps_telemetry.h" #include "gps_navigation_message.h" namespace sc = boost::statechart; diff --git a/src/core/system_parameters/GPS_L1_CA.h b/src/core/system_parameters/GPS_L1_CA.h index ecb0fc753..b1cf98887 100644 --- a/src/core/system_parameters/GPS_L1_CA.h +++ b/src/core/system_parameters/GPS_L1_CA.h @@ -76,7 +76,7 @@ const int GPS_WORD_BITS=30; //!< Number of bits per word in t -#define num_of_slices(x) sizeof(x)/sizeof(bits_slice) + /*! * \brief Navigation message bits slice structure: A portion of bits is indicated by diff --git a/src/core/system_parameters/gps_navigation_message.cc b/src/core/system_parameters/gps_navigation_message.cc index 439293770..5c9a3f3e0 100644 --- a/src/core/system_parameters/gps_navigation_message.cc +++ b/src/core/system_parameters/gps_navigation_message.cc @@ -32,6 +32,10 @@ #include "gps_navigation_message.h" + +#define num_of_slices(x) sizeof(x)/sizeof(bits_slice) + + void gps_navigation_message::reset() { d_TOW=0; @@ -129,6 +133,13 @@ gps_navigation_message::gps_navigation_message() +void gps_navigation_message::print_gps_word_bytes(unsigned int GPS_word) +{ + std::cout << " Word ="; + std::cout<(GPS_word); + std::cout< bits, const bits_slice *slices) @@ -154,6 +165,7 @@ bool gps_navigation_message::read_navigation_bool(std::bitset unsigned long int gps_navigation_message::read_navigation_unsigned(std::bitset bits, const bits_slice *slices, int num_of_slices) { unsigned long int value; + value=0; for (int i=0;i bits, const bits_slice *slices, int num_of_slices); signed long int read_navigation_signed(std::bitset bits, const bits_slice *slices, int num_of_slices); bool read_navigation_bool(std::bitset bits, const bits_slice *slices); + void print_gps_word_bytes(unsigned int GPS_word); /* * Accounts for the beginning or end of week crossover diff --git a/src/core/system_parameters/gps_telemetry.cc b/src/core/system_parameters/gps_telemetry.cc deleted file mode 100644 index 3538fe87d..000000000 --- a/src/core/system_parameters/gps_telemetry.cc +++ /dev/null @@ -1,99 +0,0 @@ -/*! - * \file gps_telemetry.cc - * \brief GPS L1 C/A telemetry processing - * \author Javier Arribas, 2011. jarribas(at)cttc.es - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) - * - * 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 . - * - * ------------------------------------------------------------------------- - */ - -#include "gps_telemetry.h" - -#include -#include -#include - -bool gps_word_parityCheck(unsigned int gpsword) -{ - unsigned int d1,d2,d3,d4,d5,d6,d7,t,parity; - - /* XOR as many bits in parallel as possible. The magic constants pick - up bits which are to be XOR'ed together to implement the GPS parity - check algorithm described in ICD-GPS-200. This avoids lengthy shift- - and-xor loops. */ - - 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; - - t = d1 ^ d2 ^ d3 ^ d4 ^ d5 ^ d6 ^ d7; - - // 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; - if (parity == (gpsword&0x3F)) - return(true); - else - return(false); - -} - -char bit_mask(int num_bits) -{ - char mask; - mask=1; - for (int i=0;i<(num_bits-1);i++) - { - mask<<=1; - mask++; - } - return mask; -} - -char bit_select(int num_bit) -{ - char mask; - mask=1; - for (int i=0;i<(num_bit-1);i++) - { - mask<<=1; - } - return mask; -} - -void print_gps_word_bytes(unsigned int GPS_word) -{ - std::cout << " Word ="; - std::cout<(GPS_word); - std::cout<. - * - * ------------------------------------------------------------------------- - */ -#ifndef GNSS_SDR_GPS_TELEMETRY_H_ -#define GNSS_SDR_GPS_TELEMETRY_H_ - -#define _lrotl(X,N) ((X << N) ^ (X >> (32-N))) //!< Used in the parity check algorithm - -#include "GPS_L1_CA.h" - -bool gps_word_parityCheck(unsigned int gpsword); -char bit_mask(int num_bits); -char bit_select(int num_bit); -void print_gps_word_bytes(unsigned int GPS_word); - -#endif diff --git a/src/core/system_parameters/jamfile.jam b/src/core/system_parameters/jamfile.jam index e88c789f3..560701144 100644 --- a/src/core/system_parameters/jamfile.jam +++ b/src/core/system_parameters/jamfile.jam @@ -1,4 +1,3 @@ project : build-dir ../../../build ; obj gps_navigation_message : gps_navigation_message.cc ; -obj gps_telemetry : gps_telemetry.cc ; \ No newline at end of file diff --git a/src/main/jamfile.jam b/src/main/jamfile.jam index 0b86c6f6b..56a7d30c2 100644 --- a/src/main/jamfile.jam +++ b/src/main/jamfile.jam @@ -51,7 +51,6 @@ exe gnss-sdr : main.cc ../core/receiver//gnss_block_factory ../core/receiver//gnss_flowgraph ../core/system_parameters//gps_navigation_message -../core/system_parameters//gps_telemetry ../..//gflags ../..//glog ../..//gnuradio-core ;