fun_ofdm
1.0
802.11a Physical Layer for USRP
|
The receiver class is the public interface for the fun_ofdm receiver. This is the easiest way to start receiving 802.11a OFDM frames out of the box. More...
#include <receiver.h>
Public Member Functions | |
receiver (void(*callback)(std::vector< std::vector< unsigned char > > packets), double freq=5.72e9, double samp_rate=5e6, double rx_gain=20, std::string device_addr="") | |
Constructor for the receiver with raw parameters. More... | |
receiver (void(*callback)(std::vector< std::vector< unsigned char > > packets), usrp_params params=usrp_params()) | |
Constructor for the receiver that uses the usrp_params struct. More... | |
void | pause () |
Pauses the receiver thread. More... | |
void | resume () |
Resumes the receiver thread after it has been paused. More... | |
Private Member Functions | |
void | receiver_chain_loop () |
Infinite while loop where samples are received from USRP and processed by the receiver_chain. More... | |
Private Attributes | |
void(* | m_callback )(std::vector< std::vector< unsigned char > > packets) |
Callback function pointer. More... | |
usrp | m_usrp |
The usrp object used to receiver frames over the air. More... | |
receiver_chain | m_rec_chain |
The receiver chain object used to detect & decode incoming frames. More... | |
std::vector< std::complex < double > > | m_samples |
Vector to hold the raw samples received from the USRP and passed into the receiver_chain. More... | |
std::thread | m_rec_thread |
The thread that the receiver chain runs in. More... | |
sem_t | m_pause |
Semaphore used to pause the receiver thread. More... | |
The receiver class is the public interface for the fun_ofdm receiver. This is the easiest way to start receiving 802.11a OFDM frames out of the box.
Usage: To receive packets simply create a receiver object and pass it a callback function that takes a std::vector<std::vector<unsigned char> > as an input parameter. The receiver object then automatically creates a separate thread that pulls samples from the USRP and processes them with the receive chain. The received packets (if any) are then passed into the callback function where the user is able to process them further.
If at any time the user wishes to pause the receiver (i.e. so that the user can transmit some packets) the user simply needs to call the receiver::pause() function on the receiver object. Similarly, the receiver::resume() function can then be used to begin receiving again after a pause.
Definition at line 36 of file receiver.h.
fun::receiver::receiver | ( | void(*)(std::vector< std::vector< unsigned char > > packets) | callback, |
double | freq = 5.72e9 , |
||
double | samp_rate = 5e6 , |
||
double | rx_gain = 20 , |
||
std::string | device_addr = "" |
||
) |
Constructor for the receiver with raw parameters.
callback | Function pointer to the callback function where received packets are passed |
freq | [Optional] Center frequency |
samp_rate | [Optional] Sample Rate |
rx_gain | [Optional] Receive Gain |
device_addr | [Optional] IP address of USRP device |
Defaults to:
This constructor shows exactly what parameters need to be set for the receiver.
Definition at line 16 of file receiver.cpp.
fun::receiver::receiver | ( | void(*)(std::vector< std::vector< unsigned char > > packets) | callback, |
usrp_params | params = usrp_params() |
||
) |
Constructor for the receiver that uses the usrp_params struct.
callback | Function pointer to the callback function where received packets are passed |
params | [Optional] The usrp parameters you want to use for this receiver. |
Defaults to:
This constructor is for those who feel more comfortable using the usrp_params struct.
Definition at line 24 of file receiver.cpp.
References m_pause, m_rec_thread, and receiver_chain_loop().
void fun::receiver::pause | ( | ) |
Pauses the receiver thread.
Uses an internal semaphore to block the execution of the receiver loop code effectively pausing the receiver until the semaphore is posted to (cleared) by the receiver::resume() function.
Definition at line 64 of file receiver.cpp.
References m_pause.
Referenced by main(), and test_rx_pause().
|
private |
Infinite while loop where samples are received from USRP and processed by the receiver_chain.
This function loops forever (unless it is paused) pulling samples from the USRP and passing them through the receiver chain. It then passes any successfully decoded packets to the callback function for the user to process further. This function can be paused by the user by calling the receiver::pause() function, presumably so that the user can transmit packets over the air using the transmitter. Once the user is finished transmitting he/she can resume the receiver by called the receiver::resume() function. These two functions use an internal semaphore to block the receiver code execution while in the paused state.
Definition at line 42 of file receiver.cpp.
References fun::usrp::get_samples(), m_callback, m_pause, m_rec_chain, m_samples, m_usrp, NUM_RX_SAMPLES, and fun::receiver_chain::process_samples().
Referenced by receiver().
void fun::receiver::resume | ( | ) |
Resumes the receiver thread after it has been paused.
This function posts to (clears) the internal semaphore that is blocking the receiver loop code execution due to a previous call to the receiver::pause() function, thus allowing the main receiver loop to begin executing again.
Definition at line 74 of file receiver.cpp.
References m_pause.
Referenced by main(), and test_rx_pause().
|
private |
Callback function pointer.
Definition at line 89 of file receiver.h.
Referenced by receiver_chain_loop().
|
private |
Semaphore used to pause the receiver thread.
Definition at line 99 of file receiver.h.
Referenced by pause(), receiver(), receiver_chain_loop(), and resume().
|
private |
The receiver chain object used to detect & decode incoming frames.
Definition at line 93 of file receiver.h.
Referenced by receiver_chain_loop().
|
private |
The thread that the receiver chain runs in.
Definition at line 97 of file receiver.h.
Referenced by receiver().
|
private |
Vector to hold the raw samples received from the USRP and passed into the receiver_chain.
Definition at line 95 of file receiver.h.
Referenced by receiver_chain_loop().
|
private |
The usrp object used to receiver frames over the air.
Definition at line 91 of file receiver.h.
Referenced by receiver_chain_loop().