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
receiver.cpp
Go to the documentation of this file.
1
8
#include "
receiver.h
"
9
10
namespace
fun
11
{
12
16
receiver::receiver
(
void
(*
callback
)(std::vector<std::vector<unsigned char> > packets),
double
freq
,
double
samp_rate,
double
rx_gain
, std::string device_addr) :
17
receiver
(
callback
,
usrp_params
(freq, samp_rate, 20, rx_gain, 1.0, device_addr))
18
{
19
}
20
24
receiver::receiver
(
void
(*
callback
)(std::vector<std::vector<unsigned char> > packets),
usrp_params
params) :
25
m_usrp(params),
26
m_samples(
NUM_RX_SAMPLES
),
27
m_callback(
callback
),
28
m_rec_chain()
29
{
30
sem_init(&
m_pause
, 0, 1);
//Initial value is 1 so that the receiver_chain_loop() will begin executing immediately
31
m_rec_thread
= std::thread(&
receiver::receiver_chain_loop
,
this
);
//Initialize the main receiver thread
32
}
33
42
void
receiver::receiver_chain_loop
()
43
{
44
while
(1)
45
{
46
sem_wait(&
m_pause
);
// Block if the receiver is paused
47
48
m_usrp
.
get_samples
(
NUM_RX_SAMPLES
,
m_samples
);
49
50
std::vector<std::vector<unsigned char> > packets =
51
m_rec_chain
.
process_samples
(
m_samples
);
52
53
m_callback
(packets);
54
55
sem_post(&
m_pause
);
// Flags the end of this loop and wakes up any other threads waiting on this semaphore
56
// i.e. a call to the pause() function in the main thread.
57
}
58
}
59
64
void
receiver::pause
()
65
{
66
sem_wait(&
m_pause
);
67
}
68
74
void
receiver::resume
()
75
{
76
sem_post(&
m_pause
);
77
}
78
}
src
receiver.cpp
Generated on Mon Oct 20 2014 10:26:27 for fun_ofdm by
1.8.4