fun_ofdm  1.0
802.11a Physical Layer for USRP
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
test_rx.cpp
Go to the documentation of this file.
1 
8 #include <iostream>
9 #include <boost/date_time/posix_time/posix_time.hpp>
10 #include <boost/date_time/gregorian/gregorian.hpp>
11 #include <boost/program_options.hpp>
12 #include "receiver.h"
13 
14 using namespace fun;
15 
16 void test_rx(double freq, double sample_rate, double rx_gain);
17 void test_rx_pause(double freq, double rate, double rx_gain);
18 void process_packets_callback(std::vector<std::vector<unsigned char> > packets);
19 
20 double freq = 5.72e9;
21 double sample_rate = 5e6;
22 //double tx_gain = 30;
23 double rx_gain = 30;
24 //double amp = 0.5;
25 //Rate phy_rate = RATE_1_2_BPSK;
26 
27 int rx_count = 0;
28 
29 int main(int argc, char * argv[]){
30 
31  std::cout << "Testing receive chain..." << std::endl;
32 
34 
35 // test_rx_pause(freq, sample_rate, rx_gain);
36 
37  return 0;
38 }
39 
40 
54 void test_rx(double freq, double sample_rate, double rx_gain)
55 {
56 
57  // Instantiate a usrp
58  printf("Instantiating the usrp.\n");
59 
60  receiver rx = receiver(&process_packets_callback, freq, sample_rate, rx_gain, "");
61 
62  while(1);
63 }
64 
65 
79 void test_rx_pause(double freq, double sample_rate, double rx_gain)
80 {
81 
82  // Instantiate a usrp
83  printf("Instantiating the usrp.\n");
84  receiver rx = receiver(&process_packets_callback, freq, sample_rate, rx_gain, "");
85 
86  while(1)
87  {
88  sleep(4);
89 
90  std::cout << "Pausing Receiver for 1 second " << std::endl;
91  rx.pause();
92 
93  sleep(1);
94 
95  std::cout << "Resuming the Receiver" << std::endl;
96  rx.resume();
97 
98  }
99 }
100 
101 
109 void process_packets_callback(std::vector<std::vector<unsigned char> > packets)
110 {
111  rx_count += packets.size();
112 
113  boost::posix_time::ptime rx_time = boost::posix_time::microsec_clock::local_time();
114  if(packets.size() > 0)
115  {
116  std::cout << "Received " << rx_count << " packets at " << rx_time.time_of_day() << std::endl;
117  }
118 
119 }
120 
121