blah2
A real-time passive radar
RspDuo Class Reference

A class to capture data on the SDRplay RspDuo. More...

#include <RspDuo.h>

Collaboration diagram for RspDuo:
Collaboration graph

Public Member Functions

 RspDuo (uint32_t fc, std::string path)
 Constructor. More...
 
std::string set_file (std::string path)
 Get file name from path. More...
 
void start ()
 Call methods to start capture. More...
 
void stop ()
 Call methods to gracefully stop capture. More...
 
void process (IqData *buffer1, IqData *buffer2)
 Implement capture function on RSPduo. More...
 
void replay (IqData *buffer1, IqData *buffer2, std::string file, bool loop)
 Implement replay function on RSPduo. More...
 
void open_file ()
 Open a new file to record IQ. More...
 
void close_file ()
 Close IQ file gracefully. More...
 
void set_capture (bool capture)
 Setter for capture. More...
 
bool get_capture ()
 Getter for capture. More...
 

Private Member Functions

void validate ()
 Check parameters for valid for capture device. More...
 
void open_api ()
 Start API functions. More...
 
void get_device ()
 Device selection function. More...
 
void set_device_parameters ()
 Set device parameters. More...
 
void stream_a_callback (short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext)
 Tuner a callback as defined in SDRplay API. More...
 
void stream_b_callback (short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext)
 Tuner b callback as defined in SDRplay API. More...
 
void event_callback (sdrplay_api_EventT eventId, sdrplay_api_TunerSelectT tuner, sdrplay_api_EventParamsT *params, void *cbContext)
 Event callback function as defined in SDRplay API. More...
 
void initialise_device ()
 Start running capture callback function. More...
 
void uninitialise_device ()
 Stop running capture callback function. More...
 
void finish ()
 Internal method to gracefully stop capture.. More...
 

Static Private Member Functions

static void _stream_a_callback (short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext)
 Wrapper for C style callback function for stream_a_callback(). More...
 
static void _stream_b_callback (short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext)
 Wrapper for C style callback function for stream_b_callback(). More...
 
static void _event_callback (sdrplay_api_EventT eventId, sdrplay_api_TunerSelectT tuner, sdrplay_api_EventParamsT *params, void *cbContext)
 Wrapper for C style callback function for event_callback(). More...
 

Private Attributes

uint32_t fc
 Center frequency (Hz) More...
 
int chunk_time_nr
 chunk time of recording (s) More...
 
int agc_bandwidth_nr
 AGC bandwidth (Hz) More...
 
int agc_set_point_nr
 AGC set point (dBfs) More...
 
int gain_reduction_nr
 Gain reduction (dB). More...
 
int lna_state_nr
 LNA state. More...
 
int nDecimation
 Decimation factor (integer). More...
 
bool rf_notch_fg
 MW and FM notch filters. More...
 
bool dab_notch_fg
 DAB notch filter. More...
 
bool usb_bulk_fg
 USB bulk transfer mode. More...
 
bool small_verbose_fg
 Debugging. More...
 
bool more_verbose_fg
 Debugging. More...
 
std::string path
 File path. More...
 
bool capture
 True if capture is enabled. More...
 

Static Private Attributes

static const double MAX_FREQUENCY_NR = 2000000000
 Maximum frequency (Hz). More...
 
static const uint8_t DEF_DECIMATION_NR = 1
 Default decimation. More...
 
static const int DEF_WAIT_TIME_NR = 0
 Default wait time before recording. More...
 
static const int DEF_CHUNK_TIME_NR = 0
 Default chunk time of recording. More...
 
static const int MAX_RUN_TIME_NR = 86400
 Maximum run time of recording. More...
 
static const int DEF_AGC_BANDWIDTH_NR = 50
 Default AGC bandwidth. More...
 
static const int MIN_AGC_SET_POINT_NR = -72
 Minimum AGC set point. More...
 
static const int DEF_AGC_SET_POINT_NR = -60
 Default AGC set point. More...
 
static const int MIN_GAIN_REDUCTION_NR = 20
 Minimum gain reduction. More...
 
static const int DEF_GAIN_REDUCTION_NR = 40
 Default gain reduction. More...
 
static const int MAX_GAIN_REDUCTION_NR = 60
 Maximum gain reduction. More...
 
static const int DEF_LNA_STATE_NR = 4
 Default LNA state. More...
 
static const int MAX_LNA_STATE_NR = 9
 Max LNA state. More...
 
static const int DEF_SAMPLE_FREQUENCY_NR = 6000000
 Default sample frequency. More...
 
static const int DEF_SAMPLE_RATE_NR = 2000000
 Default sample rate. More...
 

Detailed Description

A class to capture data on the SDRplay RspDuo.

Loosely based upon the sdrplay_api_sample_app.c and sdr_play.c examples provided in the SDRplay API V3 documentation. This should be read in conjuction with that documentation

For coherent operation the use of sdrplay_api_Tuner_Both is most important This clue was provided by Gustaw Mazurek of WUT https://github.com/fventuri/gr-sdrplay/issues/2 https://github.com/g4eev/RSPduoEME/blob/main/rspduointerface.cpp

Reference for using C style callback API with a C++ wrapper: https://stackoverflow.com/questions/63768893/pointer-problem-using-functions-from-non-object-api-in-objects?rq=1

Author
30hours
Michael P
Todo:
Remove max time.

Constructor & Destructor Documentation

◆ RspDuo()

RspDuo::RspDuo ( uint32_t  fc,
std::string  path 
)

Constructor.

Parameters
fcCenter frequency (Hz).
pathPath to save IQ data.
Returns
The object.

Member Function Documentation

◆ _event_callback()

static void RspDuo::_event_callback ( sdrplay_api_EventT  eventId,
sdrplay_api_TunerSelectT  tuner,
sdrplay_api_EventParamsT *  params,
void *  cbContext 
)
inlinestaticprivate

Wrapper for C style callback function for event_callback().

Parameters
eventIdAs defined in SDRplay API.
tunerAs defined in SDRplay API.
paramsAs defined in SDRplay API.
cbContextAs defined in SDRplay API.
Returns
Void.

◆ _stream_a_callback()

static void RspDuo::_stream_a_callback ( short *  xi,
short *  xq,
sdrplay_api_StreamCbParamsT *  params,
unsigned int  numSamples,
unsigned int  reset,
void *  cbContext 
)
inlinestaticprivate

Wrapper for C style callback function for stream_a_callback().

Parameters
xiPointer to real part of sample.
xqPointer to imag part of sample.
paramsAs defined in SDRplay API.
numSamplesNumber of samples in block.
resetAs defined in SDRplay API.
cbContextAs defined in SDRplay API.
Returns
Void.

◆ _stream_b_callback()

static void RspDuo::_stream_b_callback ( short *  xi,
short *  xq,
sdrplay_api_StreamCbParamsT *  params,
unsigned int  numSamples,
unsigned int  reset,
void *  cbContext 
)
inlinestaticprivate

Wrapper for C style callback function for stream_b_callback().

Parameters
xiPointer to real part of sample.
xqPointer to imag part of sample.
paramsAs defined in SDRplay API.
numSamplesNumber of samples in block.
resetAs defined in SDRplay API.
cbContextAs defined in SDRplay API.
Returns
Void.

◆ close_file()

void RspDuo::close_file ( )

Close IQ file gracefully.

Returns
Void.

◆ event_callback()

void RspDuo::event_callback ( sdrplay_api_EventT  eventId,
sdrplay_api_TunerSelectT  tuner,
sdrplay_api_EventParamsT *  params,
void *  cbContext 
)
private

Event callback function as defined in SDRplay API.

Parameters
eventIdAs defined in SDRplay API.
tunerAs defined in SDRplay API.
paramsAs defined in SDRplay API.
cbContextAs defined in SDRplay API.
Returns
Void.

◆ finish()

void RspDuo::finish ( )
private

Internal method to gracefully stop capture..

Returns
Void.

◆ get_capture()

bool RspDuo::get_capture ( )

Getter for capture.

Returns
True if capture is true.

◆ get_device()

void RspDuo::get_device ( )
private

Device selection function.

Returns
The object.

◆ initialise_device()

void RspDuo::initialise_device ( )
private

Start running capture callback function.

Returns
Void.

◆ open_api()

void RspDuo::open_api ( )
private

Start API functions.

Returns
The object.

◆ open_file()

void RspDuo::open_file ( )

Open a new file to record IQ.

Returns
Void.

◆ process()

void RspDuo::process ( IqData buffer1,
IqData buffer2 
)

Implement capture function on RSPduo.

Parameters
buffer1Pointer to reference buffer.
buffer2Pointer to surveillance buffer.
Returns
Void.

◆ replay()

void RspDuo::replay ( IqData buffer1,
IqData buffer2,
std::string  file,
bool  loop 
)

Implement replay function on RSPduo.

Parameters
buffer1Pointer to reference buffer.
buffer2Pointer to surveillance buffer.
filePath to file to replay data from.
loopTrue if samples should loop at EOF.
Returns
Void.

◆ set_capture()

void RspDuo::set_capture ( bool  capture)

Setter for capture.

Parameters
captureTrue if capture is enabled.
Returns
Void.

◆ set_device_parameters()

void RspDuo::set_device_parameters ( )
private

Set device parameters.

Returns
The object.

◆ set_file()

std::string RspDuo::set_file ( std::string  path)

Get file name from path.

Returns
String of file name based on current time.

◆ start()

void RspDuo::start ( )

Call methods to start capture.

Returns
Void.

◆ stop()

void RspDuo::stop ( )

Call methods to gracefully stop capture.

Returns
Void.

◆ stream_a_callback()

void RspDuo::stream_a_callback ( short *  xi,
short *  xq,
sdrplay_api_StreamCbParamsT *  params,
unsigned int  numSamples,
unsigned int  reset,
void *  cbContext 
)
private

Tuner a callback as defined in SDRplay API.

Parameters
xiPointer to real part of sample.
xqPointer to imag part of sample.
paramsAs defined in SDRplay API.
numSamplesNumber of samples in block.
resetAs defined in SDRplay API.
cbContextAs defined in SDRplay API.
Returns
Void.

◆ stream_b_callback()

void RspDuo::stream_b_callback ( short *  xi,
short *  xq,
sdrplay_api_StreamCbParamsT *  params,
unsigned int  numSamples,
unsigned int  reset,
void *  cbContext 
)
private

Tuner b callback as defined in SDRplay API.

Parameters
xiPointer to real part of sample.
xqPointer to imag part of sample.
paramsAs defined in SDRplay API.
numSamplesNumber of samples in block.
resetAs defined in SDRplay API.
cbContextAs defined in SDRplay API.
Returns
Void.

◆ uninitialise_device()

void RspDuo::uninitialise_device ( )
private

Stop running capture callback function.

Returns
Void.

◆ validate()

void RspDuo::validate ( )
private

Check parameters for valid for capture device.

Returns
The object.

Member Data Documentation

◆ agc_bandwidth_nr

int RspDuo::agc_bandwidth_nr
private

AGC bandwidth (Hz)

◆ agc_set_point_nr

int RspDuo::agc_set_point_nr
private

AGC set point (dBfs)

◆ capture

bool RspDuo::capture
private

True if capture is enabled.

◆ chunk_time_nr

int RspDuo::chunk_time_nr
private

chunk time of recording (s)

◆ dab_notch_fg

bool RspDuo::dab_notch_fg
private

DAB notch filter.

◆ DEF_AGC_BANDWIDTH_NR

const int RspDuo::DEF_AGC_BANDWIDTH_NR = 50
staticprivate

Default AGC bandwidth.

◆ DEF_AGC_SET_POINT_NR

const int RspDuo::DEF_AGC_SET_POINT_NR = -60
staticprivate

Default AGC set point.

◆ DEF_CHUNK_TIME_NR

const int RspDuo::DEF_CHUNK_TIME_NR = 0
staticprivate

Default chunk time of recording.

◆ DEF_DECIMATION_NR

const uint8_t RspDuo::DEF_DECIMATION_NR = 1
staticprivate

Default decimation.

◆ DEF_GAIN_REDUCTION_NR

const int RspDuo::DEF_GAIN_REDUCTION_NR = 40
staticprivate

Default gain reduction.

◆ DEF_LNA_STATE_NR

const int RspDuo::DEF_LNA_STATE_NR = 4
staticprivate

Default LNA state.

◆ DEF_SAMPLE_FREQUENCY_NR

const int RspDuo::DEF_SAMPLE_FREQUENCY_NR = 6000000
staticprivate

Default sample frequency.

◆ DEF_SAMPLE_RATE_NR

const int RspDuo::DEF_SAMPLE_RATE_NR = 2000000
staticprivate

Default sample rate.

◆ DEF_WAIT_TIME_NR

const int RspDuo::DEF_WAIT_TIME_NR = 0
staticprivate

Default wait time before recording.

◆ fc

uint32_t RspDuo::fc
private

Center frequency (Hz)

◆ gain_reduction_nr

int RspDuo::gain_reduction_nr
private

Gain reduction (dB).

◆ lna_state_nr

int RspDuo::lna_state_nr
private

LNA state.

◆ MAX_FREQUENCY_NR

const double RspDuo::MAX_FREQUENCY_NR = 2000000000
staticprivate

Maximum frequency (Hz).

◆ MAX_GAIN_REDUCTION_NR

const int RspDuo::MAX_GAIN_REDUCTION_NR = 60
staticprivate

Maximum gain reduction.

◆ MAX_LNA_STATE_NR

const int RspDuo::MAX_LNA_STATE_NR = 9
staticprivate

Max LNA state.

◆ MAX_RUN_TIME_NR

const int RspDuo::MAX_RUN_TIME_NR = 86400
staticprivate

Maximum run time of recording.

◆ MIN_AGC_SET_POINT_NR

const int RspDuo::MIN_AGC_SET_POINT_NR = -72
staticprivate

Minimum AGC set point.

◆ MIN_GAIN_REDUCTION_NR

const int RspDuo::MIN_GAIN_REDUCTION_NR = 20
staticprivate

Minimum gain reduction.

◆ more_verbose_fg

bool RspDuo::more_verbose_fg
private

Debugging.

◆ nDecimation

int RspDuo::nDecimation
private

Decimation factor (integer).

◆ path

std::string RspDuo::path
private

File path.

◆ rf_notch_fg

bool RspDuo::rf_notch_fg
private

MW and FM notch filters.

◆ small_verbose_fg

bool RspDuo::small_verbose_fg
private

Debugging.

◆ usb_bulk_fg

bool RspDuo::usb_bulk_fg
private

USB bulk transfer mode.


The documentation for this class was generated from the following files: