diff options
author | Johnathan Corgan <jcorgan@corganenterprises.com> | 2009-11-06 11:21:08 -0800 |
---|---|---|
committer | Johnathan Corgan <jcorgan@corganenterprises.com> | 2009-11-09 08:05:23 -0800 |
commit | 4e0c8a37c3574f59e34186996cef0c44ff50bd16 (patch) | |
tree | a922b56ebe5f8e3f8ef489cc813a373e5a066f16 /gr-noaa/lib | |
parent | df6839b8d323aa11e5739f8597a95e38745ac2e4 (diff) |
gr-noaa: added HRPT minor frame parsing, renamed scripts
implemented start of minor frame parsing
renamed demod_rx_hrpt to hrpt_demod, new defaults
added configuration flags to hrpt_decoder
added hrpt_decode app
updated file_rx_hrpt with new defaults
updated usrp_rx_hrpt_* with new defaults
Diffstat (limited to 'gr-noaa/lib')
-rw-r--r-- | gr-noaa/lib/Makefile.am | 3 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt.h | 39 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_decoder.cc | 167 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_decoder.h | 39 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_deframer.cc | 26 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_deframer.h | 4 |
6 files changed, 228 insertions, 50 deletions
diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index 4ef4eb87bd..f01bbfab89 100644 --- a/gr-noaa/lib/Makefile.am +++ b/gr-noaa/lib/Makefile.am @@ -33,6 +33,9 @@ libgnuradio_noaa_la_SOURCES = \ noaa_hrpt_deframer.cc \ noaa_hrpt_pll_cf.cc +noinst_HEADERS = \ + noaa_hrpt.h + libgnuradio_noaa_la_LIBADD = \ $(GNURADIO_CORE_LA) diff --git a/gr-noaa/lib/noaa_hrpt.h b/gr-noaa/lib/noaa_hrpt.h new file mode 100644 index 0000000000..3812e93685 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt.h @@ -0,0 +1,39 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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, or (at your option) + * any later version. + * + * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_NOAA_HRPT_H +#define INCLUDED_NOAA_HRPT_H + +#define HRPT_SYNC1 0x0284 +#define HRPT_SYNC2 0x016F +#define HRPT_SYNC3 0x035C +#define HRPT_SYNC4 0x019D +#define HRPT_SYNC5 0x020F +#define HRPT_SYNC6 0x0095 + +#define HRPT_MINOR_FRAME_SYNC 0x0A116FD719D83C95LL + +#define HRPT_SYNC_WORDS 6 +#define HRPT_MINOR_FRAME_WORDS 11090 +#define HRPT_BITS_PER_WORD 10 + +#endif /* INCLUDED_NOAA_HRPT_H */ diff --git a/gr-noaa/lib/noaa_hrpt_decoder.cc b/gr-noaa/lib/noaa_hrpt_decoder.cc index 8cfaa913c4..2433100891 100644 --- a/gr-noaa/lib/noaa_hrpt_decoder.cc +++ b/gr-noaa/lib/noaa_hrpt_decoder.cc @@ -25,27 +25,52 @@ #endif #include <noaa_hrpt_decoder.h> +#include <noaa_hrpt.h> #include <gr_io_signature.h> +#include <cstdio> -#define SYNC1 0x0284 -#define SYNC2 0x016F -#define SYNC3 0x035C -#define SYNC4 0x019D -#define SYNC5 0x020F -#define SYNC6 0x0095 +static const char *hrpt_ids[] = { + "000000", + "NOAA11", + "000002", + "NOAA16", + "000004", + "000005", + "000006", + "NOAA15", + "000008", + "NOAA12", + "000010", + "NOAA17", + "000012", + "NOAA18", + "000014", + "NOAA19" +}; noaa_hrpt_decoder_sptr -noaa_make_hrpt_decoder() +noaa_make_hrpt_decoder(bool verbose, bool output_files) { - return gnuradio::get_initial_sptr(new noaa_hrpt_decoder()); + return gnuradio::get_initial_sptr(new noaa_hrpt_decoder(verbose, output_files)); } -noaa_hrpt_decoder::noaa_hrpt_decoder() +noaa_hrpt_decoder::noaa_hrpt_decoder(bool verbose, bool output_files) : gr_sync_block("noaa_hrpt_decoder", gr_make_io_signature(1, 1, sizeof(short)), - gr_make_io_signature(0, 0, 0)) + gr_make_io_signature(0, 0, 0)), + d_verbose(verbose), + d_output_files(output_files), + d_word_num(0), + d_frames_seen(0), + d_current_mfnum(0), + d_expected_mfnum(0), + d_seq_errs(0), + d_address(0), + d_day_of_year(0), + d_milliseconds(0), + d_last_time(0) { - d_word_count = 0; + // Start of capture processing here } int @@ -57,21 +82,119 @@ noaa_hrpt_decoder::work(int noutput_items, int i = 0; while (i < noutput_items) { - unsigned short word = in[i++]; - d_word_count++; - //fprintf(stderr, "%5u: ", d_word_count); - for (int pos = 0; pos < 10; pos++) { - char ch = (word & (1 << 9)) ? '1' : '0'; - word = word << 1; - //fprintf(stderr, "%c ", ch); + d_current_word = in[i++] & 0x3FF; + d_word_num++; + + // Per HRPT word processing here + + switch (d_word_num) { + case 7: + process_mfnum(); + process_address(); + break; + + case 9: + process_day_of_year(); + break; + + case 10: + process_milli1(); + break; + + case 11: + process_milli2(); + break; + + case 12: + process_milli3(); + break; + + default: + break; } - //fprintf(stderr, "\n"); - if (d_word_count == 11090) { - d_word_count = 0; - //fprintf(stderr, "\n"); + if (d_word_num == HRPT_MINOR_FRAME_WORDS) { + + // End of minor frame processing here + d_frames_seen++; + d_word_num = 0; + fprintf(stderr, "\n"); } } return i; } + +void +noaa_hrpt_decoder::process_mfnum() +{ + d_current_mfnum = (d_current_word & 0x180) >> 7; + + if (d_verbose) + fprintf(stderr, "MF:"); + + if (d_current_mfnum != d_expected_mfnum && d_frames_seen > 0) { + d_seq_errs++; + + if (d_verbose) + fprintf(stderr, "*"); + } + else + if (d_verbose) + fprintf(stderr, " "); + + if (d_verbose) + fprintf(stderr, "%i ", d_current_mfnum); + d_expected_mfnum = (d_current_mfnum == 3) ? 1 : d_current_mfnum+1; +} + +void +noaa_hrpt_decoder::process_address() +{ + d_address = ((d_current_word & 0x078) >> 3) & 0x000F; + + if (d_verbose) + fprintf(stderr, "SA: %s ", hrpt_ids[d_address]); +} + +void +noaa_hrpt_decoder::process_day_of_year() +{ + d_day_of_year = d_current_word >> 1; + + if (d_verbose) + fprintf(stderr, "DOY: %3i ", d_day_of_year); +} + +void +noaa_hrpt_decoder::process_milli1() +{ + d_milliseconds = (d_current_word & 0x7F) << 20; +} + +void +noaa_hrpt_decoder::process_milli2() +{ + d_milliseconds |= (d_current_word << 10); +} + +void +noaa_hrpt_decoder::process_milli3() +{ + d_milliseconds |= d_current_word; + int delta = d_milliseconds - d_last_time; + d_last_time = d_milliseconds; + + if (d_verbose) + fprintf(stderr, "MS: %8i DT: %8i", d_milliseconds, delta); +} + +noaa_hrpt_decoder::~noaa_hrpt_decoder() +{ + // End of capture processing here + + if (d_verbose) { + fprintf(stderr, "Frames seen: %10i\n", d_frames_seen); + fprintf(stderr, "Sequence errors: %10i\n", d_seq_errs); + } +} diff --git a/gr-noaa/lib/noaa_hrpt_decoder.h b/gr-noaa/lib/noaa_hrpt_decoder.h index 305243b09a..9d67d7108e 100644 --- a/gr-noaa/lib/noaa_hrpt_decoder.h +++ b/gr-noaa/lib/noaa_hrpt_decoder.h @@ -29,16 +29,45 @@ class noaa_hrpt_decoder; typedef boost::shared_ptr<noaa_hrpt_decoder> noaa_hrpt_decoder_sptr; noaa_hrpt_decoder_sptr -noaa_make_hrpt_decoder(); +noaa_make_hrpt_decoder(bool verbose, bool output_files); class noaa_hrpt_decoder : public gr_sync_block { - friend noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(); - noaa_hrpt_decoder(); + friend noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(bool verbose, bool output_files); + noaa_hrpt_decoder(bool verbose, bool output_files); + + // Configuration + bool d_verbose; + bool d_output_files; + + // Frame-level state + unsigned short d_current_word; + unsigned int d_word_num; + int d_frames_seen; + + // Minor frame number + int d_current_mfnum; + int d_expected_mfnum; + int d_seq_errs; + + // Spacecraft address + int d_address; + + // Minor frame timestamp + int d_day_of_year; + int d_milliseconds; + int d_last_time; + + void process_mfnum(); + void process_address(); + void process_day_of_year(); + void process_milli1(); + void process_milli2(); + void process_milli3(); - unsigned int d_word_count; - public: + ~noaa_hrpt_decoder(); + int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/gr-noaa/lib/noaa_hrpt_deframer.cc b/gr-noaa/lib/noaa_hrpt_deframer.cc index e79894869b..1a2af6c379 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.cc +++ b/gr-noaa/lib/noaa_hrpt_deframer.cc @@ -26,23 +26,13 @@ #include <noaa_hrpt_deframer.h> #include <gr_io_signature.h> +#include <noaa_hrpt.h> #include <cstring> #include <cstdio> #define ST_IDLE 0 #define ST_SYNCED 1 -#define SYNC1 0x0284 -#define SYNC2 0x016F -#define SYNC3 0x035C -#define SYNC4 0x019D -#define SYNC5 0x020F -#define SYNC6 0x0095 - -#define HRPT_MINOR_FRAME_SYNC 0x0A116FD719D83C95LL - -static int frames_seen = 0; - noaa_hrpt_deframer_sptr noaa_make_hrpt_deframer() { @@ -98,13 +88,12 @@ noaa_hrpt_deframer::general_work(int noutput_items, d_shifter = (d_shifter << 1) | bit; // MSB transmitted first if ((d_shifter & 0x0FFFFFFFFFFFFFFFLL) == HRPT_MINOR_FRAME_SYNC) { - fprintf(stderr, "SYNC #%i", frames_seen++); - out[j++] = SYNC1; - out[j++] = SYNC2; - out[j++] = SYNC3; - out[j++] = SYNC4; - out[j++] = SYNC5; - out[j++] = SYNC6; + out[j++] = HRPT_SYNC1; + out[j++] = HRPT_SYNC2; + out[j++] = HRPT_SYNC3; + out[j++] = HRPT_SYNC4; + out[j++] = HRPT_SYNC5; + out[j++] = HRPT_SYNC6; enter_synced(); } break; @@ -116,7 +105,6 @@ noaa_hrpt_deframer::general_work(int noutput_items, d_word = 0; d_bit_count = HRPT_BITS_PER_WORD; if (--d_word_count == 0) { - fprintf(stderr, "...done\n"); enter_idle(); } } diff --git a/gr-noaa/lib/noaa_hrpt_deframer.h b/gr-noaa/lib/noaa_hrpt_deframer.h index 43abba0e91..b11d0fa2b6 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.h +++ b/gr-noaa/lib/noaa_hrpt_deframer.h @@ -23,10 +23,6 @@ #ifndef INCLUDED_NOAA_HRPT_DEFRAMER_H #define INCLUDED_NOAA_HRPT_DEFRAMER_H -#define HRPT_SYNC_WORDS 6 -#define HRPT_MINOR_FRAME_WORDS 11090 -#define HRPT_BITS_PER_WORD 10 - #include <gr_block.h> class noaa_hrpt_deframer; |