fun_ofdm
1.0
802.11a Physical Layer for USRP
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Macros
Pages
frame_decoder.cpp
Go to the documentation of this file.
1
8
#include <iostream>
9
#include <cstring>
10
#include <arpa/inet.h>
11
#include <boost/crc.hpp>
12
13
#include "
frame_decoder.h
"
14
#include "
qam.h
"
15
#include "
interleaver.h
"
16
#include "
viterbi.h
"
17
#include "
parity.h
"
18
#include "
rates.h
"
19
#include "
modulator.h
"
20
#include "
puncturer.h
"
21
#include "
interleaver.h
"
22
#include "
ppdu.h
"
23
24
namespace
fun
25
{
30
frame_decoder::frame_decoder
() :
31
block
(
"frame_decoder"
),
32
m_current_frame(
FrameData
(
RateParams
(
RATE_1_2_BPSK
)))
33
{
34
m_current_frame
.
Reset
(
RateParams
(
RATE_1_2_BPSK
), 0, 0);
35
}
36
45
void
frame_decoder::work
()
46
{
47
if
(
input_buffer
.size() == 0)
return
;
48
output_buffer
.resize(0);
49
50
// Step through each 48 sample symbol
51
for
(
int
x = 0; x <
input_buffer
.size(); x++)
52
{
53
// Copy over available symbols
54
if
(
m_current_frame
.
samples_copied
<
m_current_frame
.
sample_count
)
55
{
56
memcpy(&
m_current_frame
.
samples
[
m_current_frame
.
samples_copied
], &
input_buffer
[x].samples[0], 48 *
sizeof
(std::complex<double>));
57
m_current_frame
.
samples_copied
+= 48;
58
}
59
60
// Decode the frame if possible
61
if
(
m_current_frame
.
samples_copied
>=
m_current_frame
.
sample_count
&&
m_current_frame
.
sample_count
!= 0)
62
{
63
ppdu
frame =
ppdu
(
m_current_frame
.
rate_params
.
rate
,
m_current_frame
.
length
);
64
if
(frame.
decode_data
(
m_current_frame
.
samples
))
65
{
66
output_buffer
.push_back(frame.
get_payload
());
67
}
68
m_current_frame
.
sample_count
= 0;
69
}
70
71
// Look for a start of frame
72
if
(
input_buffer
[x].tag ==
START_OF_FRAME
)
73
{
74
// Attempt to decode the header
75
ppdu
h =
ppdu
();
76
std::vector<std::complex<double> > header_samples(48);
77
memcpy(header_samples.data(),
input_buffer
[x].samples, 48 *
sizeof
(std::complex<double>));
78
if
(!h.
decode_header
(header_samples))
continue
;
79
80
// Calculate the frame sample count
81
int
length = h.
get_length
();
82
RateParams
rate_params =
RateParams
(h.
get_rate
());
83
int
frame_sample_count = h.
get_num_symbols
() * 48;
84
85
// Start a new frame
86
m_current_frame
.
Reset
(rate_params, frame_sample_count, length);
87
m_current_frame
.
samples
.resize(h.
get_num_symbols
() * 48);
88
continue
;
89
}
90
}
91
}
92
}
93
94
src
frame_decoder.cpp
Generated on Mon Oct 20 2014 10:26:27 for fun_ofdm by
1.8.4