fun_ofdm  1.0
802.11a Physical Layer for USRP
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
test_rx.cpp File Reference

Receiver test. More...

#include <iostream>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/program_options.hpp>
#include "receiver.h"

Go to the source code of this file.

Functions

void test_rx (double freq, double sample_rate, double rx_gain)
 Function for testing the fun_ofdm receiver. More...
 
void test_rx_pause (double freq, double sample_rate, double rx_gain)
 Function for testing the fun_ofdm receiver and demonstrating the use of the receiver::pause() and receiver::resume() functions. More...
 
void process_packets_callback (std::vector< std::vector< unsigned char > > packets)
 The callback function for processing the Received Packets. More...
 
int main (int argc, char *argv[])
 

Variables

double freq = 5.72e9
 
double sample_rate = 5e6
 
double rx_gain = 30
 
int rx_count = 0
 Total number of packets received since the receiver was activated. More...
 

Detailed Description

Receiver test.

This file is used to test receiving OFDM PHY frames over the air.

Definition in file test_rx.cpp.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 29 of file test_rx.cpp.

References freq, rx_gain, sample_rate, and test_rx().

29  {
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 }
void process_packets_callback ( std::vector< std::vector< unsigned char > >  packets)

The callback function for processing the Received Packets.

Parameters
packetsThe successfully received packets in from the receiver_chain

This function merely counts the number of received packets and prints the timestamps of when the packets were received.

Definition at line 109 of file test_rx.cpp.

References rx_count.

Referenced by test_rx(), and test_rx_pause().

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 }
void test_rx ( double  freq,
double  sample_rate,
double  rx_gain 
)

Function for testing the fun_ofdm receiver.

Parameters
freqCenter Frequency
sample_rateSample Rate
rx_gainReceiver Gain

This function creates a receiver object which spawns its own thread for the receiver chain. It passes a pointer to the process_packets_callback() function which is used to process the received packets (in this case it just counts them). This function then proceeds to spin forever in a while(1) loop until the user kills the program externally (preferably by using something like Ctrl+c or the kill command in the shell, however, while not suggested, pulling the power plug does also effectively kill the program).

Definition at line 54 of file test_rx.cpp.

References process_packets_callback().

Referenced by main().

55 {
56 
57  // Instantiate a usrp
58  printf("Instantiating the usrp.\n");
59 
61 
62  while(1);
63 }
void test_rx_pause ( double  freq,
double  sample_rate,
double  rx_gain 
)

Function for testing the fun_ofdm receiver and demonstrating the use of the receiver::pause() and receiver::resume() functions.

Parameters
freqCenter Frequency
sample_rateSample Rate
rx_gainReceiver Gain

This function is similar to test_rx() function, however instead of running an empty while(1) loop, it instead runs a while(1) loop that sleeps for 4 seconds allowing the receiver to run freely. It then pauses the receiver for 1 second using the receiver::pause() function, waits 1 second, then resumes the receiver by using the receiver::resume() function.

Definition at line 79 of file test_rx.cpp.

References fun::receiver::pause(), process_packets_callback(), and fun::receiver::resume().

80 {
81 
82  // Instantiate a usrp
83  printf("Instantiating the usrp.\n");
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 }

Variable Documentation

double freq = 5.72e9

Definition at line 20 of file test_rx.cpp.

Referenced by main().

int rx_count = 0

Total number of packets received since the receiver was activated.

Definition at line 27 of file test_rx.cpp.

Referenced by process_packets_callback().

double rx_gain = 30

Definition at line 23 of file test_rx.cpp.

Referenced by main().

double sample_rate = 5e6

Definition at line 21 of file test_rx.cpp.

Referenced by main().