Skip to content

Commit

Permalink
Remove bandwidth, not supported by radioberry
Browse files Browse the repository at this point in the history
  • Loading branch information
paulh002 committed May 25, 2022
1 parent 1a2e807 commit b0087c0
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 90 deletions.
156 changes: 83 additions & 73 deletions SoapyRadioberry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,112 +22,121 @@ typedef enum radioberrysdrStreamFormat {
RADIOBERRY_SDR_CS16
} radioberrysdrStreamFormat;

class SoapyRadioberry : public SoapySDR::Device{
class sdr_stream
{
public:
sdr_stream(int dir)
{
direction = dir;
}
int get_direction() { return direction; }

private:
int direction;
};

public:

SoapyRadioberry( const SoapySDR::Kwargs & args );
~SoapyRadioberry();

/*******************************************************************

class SoapyRadioberry : public SoapySDR::Device
{

public:
SoapyRadioberry(const SoapySDR::Kwargs &args);
~SoapyRadioberry();

/*******************************************************************
* Identification API
******************************************************************/

std::string getDriverKey( void ) const;
std::string getDriverKey(void) const;

std::string getHardwareKey( void ) const;
SoapySDR::Kwargs getHardwareInfo( void ) const;
/*******************************************************************
std::string getHardwareKey(void) const;

SoapySDR::Kwargs getHardwareInfo(void) const;

/*******************************************************************
* Channels API
******************************************************************/

size_t getNumChannels( const int direction ) const;
size_t getNumChannels(const int direction) const;

bool getFullDuplex( const int direction, const size_t channel ) const;
/*******************************************************************
bool getFullDuplex(const int direction, const size_t channel) const;

/*******************************************************************
* Stream API
******************************************************************/
SoapySDR::RangeList getSampleRateRange(const int direction, const size_t channel) const;

std::vector<std::string> getStreamFormats(const int direction, const size_t channel) const;

std::string getNativeStreamFormat(const int direction, const size_t channel, double &fullScale) const;

SoapySDR::ArgInfoList getStreamArgsInfo(const int direction, const size_t channel) const;


SoapySDR::Stream *setupStream(
const int direction,
const std::string &format,
const std::vector<size_t> &channels = std::vector<size_t>(),
const SoapySDR::Kwargs &args = SoapySDR::Kwargs() );
int readStream(
SoapySDR::Stream *stream,
void * const *buffs,
const size_t numElems,
int &flags,
long long &timeNs,
const long timeoutUs = 100000 );
int writeStream(
SoapySDR::Stream *stream,
const void * const *buffs,
const size_t numElems,
int &flags,
const long long timeNs = 0,
const long timeoutUs = 100000);


/*******************************************************************
SoapySDR::RangeList getSampleRateRange(const int direction, const size_t channel) const;

std::vector<std::string> getStreamFormats(const int direction, const size_t channel) const;

std::string getNativeStreamFormat(const int direction, const size_t channel, double &fullScale) const;

SoapySDR::ArgInfoList getStreamArgsInfo(const int direction, const size_t channel) const;

void closeStream(SoapySDR::Stream *stream);

SoapySDR::Stream *setupStream(
const int direction,
const std::string &format,
const std::vector<size_t> &channels = std::vector<size_t>(),
const SoapySDR::Kwargs &args = SoapySDR::Kwargs());

int readStream(
SoapySDR::Stream *stream,
void *const *buffs,
const size_t numElems,
int &flags,
long long &timeNs,
const long timeoutUs = 100000);

int writeStream(
SoapySDR::Stream *stream,
const void *const *buffs,
const size_t numElems,
int &flags,
const long long timeNs = 0,
const long timeoutUs = 100000);

/*******************************************************************
* Sample Rate API
******************************************************************/

void setSampleRate( const int direction, const size_t channel, const double rate );
void setSampleRate(const int direction, const size_t channel, const double rate);

double getBandwidth( const int direction, const size_t channel ) const;
double getBandwidth(const int direction, const size_t channel) const;

std::vector<double> listBandwidths(const int direction, const size_t channel) const;
std::vector<double> listSampleRates(const int direction, const size_t channel) const;

std::vector<double> listBandwidths( const int direction, const size_t channel ) const;
std::vector<double> listSampleRates( const int direction, const size_t channel ) const;


/*******************************************************************
/*******************************************************************
* Frequency API
******************************************************************/

void setFrequency(
const int direction,
const size_t channel,
const double frequency,
const SoapySDR::Kwargs &args = SoapySDR::Kwargs());

void setFrequency(
const int direction,
const size_t channel,
const double frequency,
const SoapySDR::Kwargs &args = SoapySDR::Kwargs());

SoapySDR::RangeList getFrequencyRange( const int direction, const size_t channel) const;

SoapySDR::RangeList getFrequencyRange(const int direction, const size_t channel) const;

/*******************************************************************
/*******************************************************************
* Antenna API
******************************************************************/

std::vector<std::string> listAntennas( const int direction, const size_t channel ) const;
std::vector<std::string> listAntennas(const int direction, const size_t channel) const;


/*******************************************************************
/*******************************************************************
* Gain API
******************************************************************/

std::vector<std::string> listGains( const int direction, const size_t channel ) const;

void setGain( const int direction, const size_t channel, const double value );
std::vector<std::string> listGains(const int direction, const size_t channel) const;

SoapySDR::Range getGainRange( const int direction, const size_t channel ) const;
void setGain(const int direction, const size_t channel, const double value);

SoapySDR::Range getGainRange(const int direction, const size_t channel) const;

void controlRadioberry(uint32_t command, uint32_t command_data);
void controlRadioberry(uint32_t command, uint32_t command_data);

/*******************************************************************
* I2C API
Expand All @@ -147,4 +156,5 @@ class SoapyRadioberry : public SoapySDR::Device{
bool i2c_available = false;
radioberrysdrStreamFormat streamFormat;
std::mutex send_command;
std::vector<sdr_stream *> streams;
};
22 changes: 6 additions & 16 deletions SoapyRadioberrySettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ SoapyRadioberry::SoapyRadioberry( const SoapySDR::Kwargs &args ){
}
}

SoapyRadioberry::~SoapyRadioberry(void){
SoapyRadioberry::~SoapyRadioberry(void)
{
SoapySDR_log(SOAPY_SDR_INFO, "SoapyRadioberry::SoapyRadioberry destructor called");

for (auto con : streams)
delete (con);
if (fd_rb != 0) close(fd_rb);
}

Expand Down Expand Up @@ -130,21 +131,10 @@ bool SoapyRadioberry::getFullDuplex( const int direction, const size_t channel )

std::vector<double> SoapyRadioberry::listBandwidths( const int direction, const size_t channel ) const
{

// radioberry does nor support bandwidth
SoapySDR_log(SOAPY_SDR_INFO, "SoapyRadioberry::listBandwidths called");



std::vector<double> options;

if (direction == SOAPY_SDR_RX) {
options.push_back(0.048e6);
options.push_back(0.096e6);
options.push_back(0.192e6);
options.push_back(0.384e6);
}
if (direction == SOAPY_SDR_TX) {
options.push_back(0.048e6);
}
return(options);
}

Expand Down
22 changes: 21 additions & 1 deletion SoapyRadioberryStreaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,28 @@ SoapySDR::Stream *SoapyRadioberry::setupStream(
"setupStream invalid format '" + format + "' -- Only CF32 is supported by SoapyRadioberrySDR module.");
}

return (SoapySDR::Stream *) this;
sdr_stream *ptr;
ptr = new sdr_stream(direction);
streams.push_back(ptr);
return (SoapySDR::Stream *)ptr;
}

void SoapyRadioberry::closeStream(SoapySDR::Stream *stream)
{
int i = 0;
for (auto con : streams)
{
if ((sdr_stream *)stream == con)
{
if (((sdr_stream *)stream)->get_direction() == SOAPY_SDR_TX)
{ // switch off TX stream
setSampleRate(SOAPY_SDR_RX, 0, sample_rate);
}
delete ((sdr_stream *)stream);
streams.erase(streams.begin() + i);
}
i++;
}
}

int SoapyRadioberry::readStream(
Expand Down

0 comments on commit b0087c0

Please sign in to comment.