3 * Copyright 2009 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
27 #include <noaa_hrpt_decoder.h>
28 #include <noaa_hrpt.h>
29 #include <gr_io_signature.h>
32 static const char *hrpt_ids[] = {
51 noaa_hrpt_decoder_sptr
52 noaa_make_hrpt_decoder(bool verbose, bool output_files)
54 return gnuradio::get_initial_sptr(new noaa_hrpt_decoder(verbose, output_files));
57 noaa_hrpt_decoder::noaa_hrpt_decoder(bool verbose, bool output_files)
58 : gr_sync_block("noaa_hrpt_decoder",
59 gr_make_io_signature(1, 1, sizeof(short)),
60 gr_make_io_signature(0, 0, 0)),
62 d_output_files(output_files),
73 // Start of capture processing here
77 noaa_hrpt_decoder::work(int noutput_items,
78 gr_vector_const_void_star &input_items,
79 gr_vector_void_star &output_items)
81 const unsigned short *in = (const unsigned short*)input_items[0];
84 while (i < noutput_items) {
85 d_current_word = in[i++] & 0x3FF;
88 // Per HRPT word processing here
97 process_day_of_year();
116 if (d_word_num == HRPT_MINOR_FRAME_WORDS) {
118 // End of minor frame processing here
121 fprintf(stderr, "\n");
129 noaa_hrpt_decoder::process_mfnum()
131 d_current_mfnum = (d_current_word & 0x180) >> 7;
134 fprintf(stderr, "MF:");
136 if (d_current_mfnum != d_expected_mfnum && d_frames_seen > 0) {
140 fprintf(stderr, "*");
144 fprintf(stderr, " ");
147 fprintf(stderr, "%i ", d_current_mfnum);
148 d_expected_mfnum = (d_current_mfnum == 3) ? 1 : d_current_mfnum+1;
152 noaa_hrpt_decoder::process_address()
154 d_address = ((d_current_word & 0x078) >> 3) & 0x000F;
157 fprintf(stderr, "SA: %s ", hrpt_ids[d_address]);
161 noaa_hrpt_decoder::process_day_of_year()
163 d_day_of_year = d_current_word >> 1;
166 fprintf(stderr, "DOY: %3i ", d_day_of_year);
170 noaa_hrpt_decoder::process_milli1()
172 d_milliseconds = (d_current_word & 0x7F) << 20;
176 noaa_hrpt_decoder::process_milli2()
178 d_milliseconds |= (d_current_word << 10);
182 noaa_hrpt_decoder::process_milli3()
184 d_milliseconds |= d_current_word;
185 int delta = d_milliseconds - d_last_time;
186 d_last_time = d_milliseconds;
189 fprintf(stderr, "MS: %8i DT: %8i", d_milliseconds, delta);
192 noaa_hrpt_decoder::~noaa_hrpt_decoder()
194 // End of capture processing here
197 fprintf(stderr, "Frames seen: %10i\n", d_frames_seen);
198 fprintf(stderr, "Sequence errors: %10i\n", d_seq_errs);