GNU Radio 3.6.5.1 C++ API
digital_simple_correlator.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2004,2013 Free Software Foundation, Inc.
4
*
5
* This file is part of GNU Radio
6
*
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)
10
* any later version.
11
*
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.
16
*
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.
21
*/
22
23
#ifndef INCLUDED_GR_SIMPLE_CORRELATOR_H
24
#define INCLUDED_GR_SIMPLE_CORRELATOR_H
25
26
#include <
digital_api.h
>
27
#include <
gr_block.h
>
28
29
class
digital_simple_correlator
;
30
typedef
boost::shared_ptr<digital_simple_correlator>
digital_simple_correlator_sptr
;
31
32
DIGITAL_API
digital_simple_correlator_sptr
digital_make_simple_correlator
(
int
payload_bytesize);
33
34
/*!
35
* \brief inverse of simple_framer (more or less)
36
* \ingroup packet_operators_blk
37
* \ingroup deprecated_blk
38
*/
39
class
DIGITAL_API
digital_simple_correlator
:
public
gr_block
40
{
41
private
:
42
static
const
int
OVERSAMPLE = 8;
43
enum
state_t { ST_LOOKING, ST_UNDER_THRESHOLD, ST_LOCKED };
44
45
int
d_payload_bytesize;
46
state_t d_state;
47
unsigned
int
d_osi;
// over sample index [0,OVERSAMPLE-1]
48
unsigned
int
d_transition_osi;
// first index where Hamming dist < thresh
49
unsigned
int
d_center_osi;
// center of bit
50
unsigned
long
long
int
d_shift_reg[OVERSAMPLE];
51
int
d_bblen;
// length of bitbuf
52
unsigned
char
*d_bitbuf;
// demodulated bits
53
unsigned
char
*d_pktbuf;
// temp packet buf
54
int
d_bbi;
// bitbuf index
55
56
static
const
int
AVG_PERIOD = 512;
// must be power of 2 (for freq offset correction)
57
int
d_avbi;
58
float
d_avgbuf[AVG_PERIOD];
59
float
d_avg;
60
float
d_accum;
61
62
#ifdef DEBUG_SIMPLE_CORRELATOR
63
FILE *d_debug_fp;
// binary log file
64
#endif
65
66
friend
GR_CORE_API
digital_simple_correlator_sptr
67
digital_make_simple_correlator
(
int
payload_bytesize);
68
digital_simple_correlator
(
int
payload_bytesize);
69
70
inline
int
slice(
float
x)
71
{
72
return
x >= d_avg ? 1 : 0;
73
}
74
75
void
update_avg(
float
x);
76
77
void
enter_locked();
78
void
enter_under_threshold();
79
void
enter_looking();
80
81
static
int
add_index(
int
a,
int
b)
82
{
83
int
t = a + b;
84
if
(t >= OVERSAMPLE)
85
t -= OVERSAMPLE;
86
assert(t >= 0 && t < OVERSAMPLE);
87
return
t;
88
}
89
90
static
int
sub_index(
int
a,
int
b)
91
{
92
int
t = a - b;
93
if
(t < 0)
94
t += OVERSAMPLE;
95
assert(t >= 0 && t < OVERSAMPLE);
96
return
t;
97
}
98
99
public
:
100
~
digital_simple_correlator
();
101
102
int
general_work
(
int
noutput_items,
103
gr_vector_int
&ninput_items,
104
gr_vector_const_void_star
&input_items,
105
gr_vector_void_star
&output_items);
106
};
107
108
#endif
/* INCLUDED_GR_SIMPLE_CORRELATOR_H */
gr-digital
include
digital_simple_correlator.h
Generated on Mon Aug 19 2013 15:37:30 for GNU Radio 3.6.5.1 C++ API by
1.8.1.2