3
* Copyright 2008 Free Software Foundation, Inc.
5
* GNU Radio is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 3, or (at your option)
10
* GNU Radio is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with GNU Radio; see the file COPYING. If not, write to
17
* the Free Software Foundation, Inc., 51 Franklin Street,
18
* Boston, MA 02110-1301, USA.
25
#include <gr_decode_ccsds_27_fb.h>
26
#include <gr_io_signature.h>
28
gr_decode_ccsds_27_fb_sptr
29
gr_make_decode_ccsds_27_fb()
31
return gr_decode_ccsds_27_fb_sptr(new gr_decode_ccsds_27_fb());
34
gr_decode_ccsds_27_fb::gr_decode_ccsds_27_fb()
35
: gr_sync_decimator("decode_ccsds_27_fb",
36
gr_make_io_signature(1, 1, sizeof(float)),
37
gr_make_io_signature(1, 1, sizeof(char)),
38
2*8) // Rate 1/2 code, unpacked to packed translation
42
float esn0 = RATE*pow(10.0, ebn0/10);
44
gen_met(d_mettab, 100, esn0, 0.0, 256);
45
viterbi_chunks_init(d_state0);
48
gr_decode_ccsds_27_fb::~gr_decode_ccsds_27_fb()
53
gr_decode_ccsds_27_fb::work(int noutput_items,
54
gr_vector_const_void_star &input_items,
55
gr_vector_void_star &output_items)
57
const float *in = (const float *)input_items[0];
58
unsigned char *out = (unsigned char *)output_items[0];
60
for (int i = 0; i < noutput_items*16; i++) {
61
// Translate and clip [-1.0..1.0] to [28..228]
62
float sample = in[i]*100.0+128.0;
65
else if (sample < 0.0)
67
unsigned char sym = (unsigned char)(floor(sample));
69
d_viterbi_in[d_count % 4] = sym;
70
if ((d_count % 4) == 3) {
71
// Every fourth symbol, perform butterfly operation
72
viterbi_butterfly2(d_viterbi_in, d_mettab, d_state0, d_state1);
74
// Every sixteenth symbol, read out a byte
75
if (d_count % 16 == 11) {
77
viterbi_get_output(d_state0, out++);
78
// printf("%li\n", *(out-1), metric);