Skip to content

Commit

Permalink
tx updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hurdad committed Jun 18, 2018
1 parent 281f874 commit e52ac7f
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 102 deletions.
10 changes: 7 additions & 3 deletions Registation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static std::vector<SoapySDR::Kwargs> findSidekiq(const SoapySDR::Kwargs &args) {
skiq_xport_type_t type = skiq_xport_type_auto;

/* query the list of all Sidekiq cards on the PCIe interface */
if(skiq_get_cards(type, &number_of_cards, card_list) < 0){
if(skiq_get_cards(type, &number_of_cards, card_list) != 0){
SoapySDR_log(SOAPY_SDR_ERROR, "Failure: skiq_get_cards");
}

Expand All @@ -23,10 +23,14 @@ static std::vector<SoapySDR::Kwargs> findSidekiq(const SoapySDR::Kwargs &args) {
bool deviceAvailable = false;

/* determine the serial number based on the card number */
skiq_read_serial_string(i, &serial_str);
if(skiq_read_serial_string(i, &serial_str) != 0){
SoapySDR_log(SOAPY_SDR_ERROR, "Failure: skiq_read_serial_string");
}

/* check if card is avail */
skiq_is_card_avail(i, &card_owner);
if(skiq_is_card_avail(i, &card_owner) != 0){
SoapySDR_log(SOAPY_SDR_ERROR, "Failure: skiq_is_card_avail");
}
deviceAvailable = (card_owner == getpid()); // owner must be this process(pid)
if (!deviceAvailable) {
SoapySDR_logf(SOAPY_SDR_WARNING, "Unable to access card #%d, owner pid (%d)", i, card_owner);
Expand Down
10 changes: 6 additions & 4 deletions Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ SoapySDR::ArgInfo SoapySidekiq::getSensorInfo(const std::string &key) const {
std::string SoapySidekiq::readSensor(const std::string &key) const {
if (key.compare("temperature")) {
int8_t temp = 0;
skiq_read_temp(card, &temp);
if (skiq_read_temp(card, &temp) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_temp (card %i)", card);
}
return std::to_string(temp);
}
bool supported = false;
Expand All @@ -25,18 +27,18 @@ std::string SoapySidekiq::readSensor(const std::string &key) const {
SoapySDR_logf(SOAPY_SDR_WARNING, "Acceleration not supported by card %i", card);
return "{}";
}
if (skiq_write_accel_state(card, 1) < 0) {// enable
if (skiq_write_accel_state(card, 1) != 0) {// enable
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_write_accel_state (card %i)", card);
return "{}";
}
int16_t x_data = 0;
int16_t y_data = 0;
int16_t z_data = 0;
if (skiq_read_accel(card, &x_data, &y_data, &z_data) < 0) {
if (skiq_read_accel(card, &x_data, &y_data, &z_data) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_accel (card %i)", card);
return "{}";
}
if (skiq_write_accel_state(card, 0) < 0) { // disable
if (skiq_write_accel_state(card, 0) != 0) { // disable
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_write_accel_state (card %i)", card);
return "{}";
};
Expand Down
50 changes: 25 additions & 25 deletions Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ SoapySidekiq::SoapySidekiq(const SoapySDR::Kwargs &args) {
SoapySDR_logf(SOAPY_SDR_DEBUG, "Sidekiq opening card %d", card);

/* init sidekiq */
if (skiq_init(type, level, &card, 1) < 0) {
if (skiq_init(type, level, &card, 1) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_init (card %d)", card);
}
}

SoapySidekiq::~SoapySidekiq(void) {
if (skiq_exit() < 0) {
if (skiq_exit() != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_exit", card);
}
}
Expand Down Expand Up @@ -119,7 +119,7 @@ bool SoapySidekiq::hasDCOffsetMode(const int direction, const size_t channel) co

void SoapySidekiq::setDCOffsetMode(const int direction, const size_t channel, const bool automatic) {
if (direction == SOAPY_SDR_RX) {
if (skiq_write_rx_dc_offset_corr(card, rx_hdl, automatic) < 0) {
if (skiq_write_rx_dc_offset_corr(card, rx_hdl, automatic) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_write_rx_dc_offset_corr (card %d, enable %d)", card, automatic);
}
}
Expand All @@ -128,7 +128,7 @@ void SoapySidekiq::setDCOffsetMode(const int direction, const size_t channel, co
bool SoapySidekiq::getDCOffsetMode(const int direction, const size_t channel) const {
bool enable;
if (direction == SOAPY_SDR_RX) {
if (skiq_read_rx_dc_offset_corr(card, rx_hdl, &enable) < 0) {
if (skiq_read_rx_dc_offset_corr(card, rx_hdl, &enable) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_rx_dc_offset_corr (card %d)", card);
}
return enable;
Expand Down Expand Up @@ -157,7 +157,7 @@ void SoapySidekiq::setGainMode(const int direction, const size_t channel, const
"Setting Sidekiq RX Gain Mode: %s",
automatic ? "skiq_rx_gain_auto" : "skiq_rx_gain_manual");
skiq_rx_gain_t mode = automatic ? skiq_rx_gain_auto : skiq_rx_gain_manual;
if (skiq_write_rx_gain_mode(card, rx_hdl, mode) < 0) {
if (skiq_write_rx_gain_mode(card, rx_hdl, mode) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_write_rx_gain_mode (card %d, mode %d)", card, mode);
}
}
Expand All @@ -166,7 +166,7 @@ void SoapySidekiq::setGainMode(const int direction, const size_t channel, const
bool SoapySidekiq::getGainMode(const int direction, const size_t channel) const {
if (direction == SOAPY_SDR_RX) {
skiq_rx_gain_t p_gain_mode;
if (skiq_read_rx_gain_mode(card, rx_hdl, &p_gain_mode) < 0) {
if (skiq_read_rx_gain_mode(card, rx_hdl, &p_gain_mode) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_rx_gain_mode (card %d)", card);
}
return p_gain_mode == skiq_rx_gain_auto;
Expand All @@ -183,7 +183,7 @@ void SoapySidekiq::setGain(const int direction, const size_t channel, const doub

void SoapySidekiq::setGain(const int direction, const size_t channel, const std::string &name, const double value) {
if (direction == SOAPY_SDR_RX) {
if (skiq_write_rx_gain(card, rx_hdl, value) < 0) {
if (skiq_write_rx_gain(card, rx_hdl, value) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_write_rx_gain (card %d, value %d)", card, value);
}
}
Expand All @@ -192,7 +192,7 @@ void SoapySidekiq::setGain(const int direction, const size_t channel, const std:
double SoapySidekiq::getGain(const int direction, const size_t channel, const std::string &name) const {
if (direction == SOAPY_SDR_RX) {
uint8_t gain_index;
if (skiq_read_rx_gain(card, rx_hdl, &gain_index) < 0) {
if (skiq_read_rx_gain(card, rx_hdl, &gain_index) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_rx_gain (card %d)", card);
}
return static_cast<double>(gain_index);
Expand All @@ -205,7 +205,7 @@ SoapySDR::Range SoapySidekiq::getGainRange(const int direction, const size_t cha
if (direction == SOAPY_SDR_RX) {
uint8_t gain_index_min;
uint8_t gain_index_max;
if (skiq_read_rx_gain_index_range(card, rx_hdl, &gain_index_min, &gain_index_max) < 0) {
if (skiq_read_rx_gain_index_range(card, rx_hdl, &gain_index_min, &gain_index_max) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_rx_gain_index_range (card %d)", card);
}
return SoapySDR::Range(gain_index_max, gain_index_max);
Expand All @@ -227,7 +227,7 @@ void SoapySidekiq::setFrequency(const int direction,
rx_center_frequency = (uint64_t) frequency;
resetBuffer = true;
SoapySDR_logf(SOAPY_SDR_DEBUG, "Setting rx center freq: %d", rx_center_frequency);
if (skiq_write_rx_LO_freq(card, rx_hdl, rx_center_frequency) < 0) {
if (skiq_write_rx_LO_freq(card, rx_hdl, rx_center_frequency) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR,
"Failure: skiq_write_rx_LO_freq (card %d, frequency %d)",
card,
Expand All @@ -239,7 +239,7 @@ void SoapySidekiq::setFrequency(const int direction,
tx_center_frequency = (uint64_t) frequency;
resetBuffer = true;
SoapySDR_logf(SOAPY_SDR_DEBUG, "Setting tx center freq: %d", tx_center_frequency);
if (skiq_write_tx_LO_freq(card, tx_hdl, tx_center_frequency) < 0) {
if (skiq_write_tx_LO_freq(card, tx_hdl, tx_center_frequency) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR,
"Failure: skiq_write_tx_LO_freq (card %d, frequency %d)",
card,
Expand All @@ -252,7 +252,7 @@ double SoapySidekiq::getFrequency(const int direction, const size_t channel, con
if (direction == SOAPY_SDR_RX && name == "RF") {
uint64_t freq;
double tuned_freq;
if (skiq_read_rx_LO_freq(card, rx_hdl, &freq, &tuned_freq) < 0) {
if (skiq_read_rx_LO_freq(card, rx_hdl, &freq, &tuned_freq) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_rx_LO_freq (card %d)", card);
}
return static_cast<double>(freq);
Expand All @@ -261,7 +261,7 @@ double SoapySidekiq::getFrequency(const int direction, const size_t channel, con
if (direction == SOAPY_SDR_TX && name == "RF") {
uint64_t freq;
double tuned_freq;
if (skiq_read_tx_LO_freq(card, tx_hdl, &freq, &tuned_freq) < 0) {
if (skiq_read_tx_LO_freq(card, tx_hdl, &freq, &tuned_freq) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_tx_LO_freq (card %d)", card);
}
return static_cast<double>(freq);
Expand All @@ -284,14 +284,14 @@ SoapySDR::RangeList SoapySidekiq::getFrequencyRange(const int direction,
uint64_t min;

if (direction == SOAPY_SDR_RX && name == "RF") {
if (skiq_read_rx_LO_freq_range(card, &max, &min) < 0) {
if (skiq_read_rx_LO_freq_range(card, &max, &min) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_rx_LO_freq_range (card %d)", card);
}
results.push_back(SoapySDR::Range(min, max));
}

if (direction == SOAPY_SDR_TX && name == "RF") {
if (skiq_read_tx_LO_freq_range(card, &max, &min) < 0) {
if (skiq_read_tx_LO_freq_range(card, &max, &min) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_tx_LO_freq_range (card %d)", card);
}
results.push_back(SoapySDR::Range(min, max));
Expand All @@ -317,7 +317,7 @@ void SoapySidekiq::setSampleRate(const int direction, const size_t channel, cons
rx_sample_rate = (uint32_t) rate;
resetBuffer = true;
SoapySDR_logf(SOAPY_SDR_DEBUG, "Setting rx sample rate: %d", rx_sample_rate);
if (skiq_write_rx_sample_rate_and_bandwidth(card, rx_hdl, rx_sample_rate, rx_bandwidth) < 0) {
if (skiq_write_rx_sample_rate_and_bandwidth(card, rx_hdl, rx_sample_rate, rx_bandwidth) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR,
"Failure: skiq_write_rx_sample_rate_and_bandwidth (card %d, sample_rate %d, bandwidth %d)",
card,
Expand All @@ -330,7 +330,7 @@ void SoapySidekiq::setSampleRate(const int direction, const size_t channel, cons
tx_sample_rate = (uint32_t) rate;
resetBuffer = true;
SoapySDR_logf(SOAPY_SDR_DEBUG, "Setting tx sample rate: %d", tx_sample_rate);
if (skiq_write_tx_sample_rate_and_bandwidth(card, tx_hdl, tx_sample_rate, tx_bandwidth) < 0) {
if (skiq_write_tx_sample_rate_and_bandwidth(card, tx_hdl, tx_sample_rate, tx_bandwidth) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR,
"Failure: skiq_write_tx_sample_rate_and_bandwidth (card %d, sample_rate %d, bandwidth %d)",
card,
Expand All @@ -344,14 +344,14 @@ double SoapySidekiq::getSampleRate(const int direction, const size_t channel) co
uint32_t rate;
double actual_rate;
if (direction == SOAPY_SDR_RX) {
if (skiq_read_rx_sample_rate(card, rx_hdl, &rate, &actual_rate) < 0) {
if (skiq_read_rx_sample_rate(card, rx_hdl, &rate, &actual_rate) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_rx_sample_rate (card %d)", card);
}
return static_cast<double>(rate);
}

if (direction == SOAPY_SDR_TX) {
if (skiq_read_tx_sample_rate(card, tx_hdl, &rate, &actual_rate)) {
if (skiq_read_tx_sample_rate(card, tx_hdl, &rate, &actual_rate) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_tx_sample_rate (card %d)", card);
}
return static_cast<double>(rate);
Expand All @@ -364,11 +364,11 @@ std::vector<double> SoapySidekiq::listSampleRates(const int direction, const siz
std::vector<double> results;

uint32_t min_sample_rate;
if (skiq_read_min_sample_rate(card, &min_sample_rate) < 0) {
if (skiq_read_min_sample_rate(card, &min_sample_rate) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_min_sample_rate (card %d)", card);
}
uint32_t max_sample_rate;
if (skiq_read_max_sample_rate(card, &max_sample_rate) < 0) {
if (skiq_read_max_sample_rate(card, &max_sample_rate) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_min_sample_rate (card %d)", card);
}

Expand All @@ -385,7 +385,7 @@ std::vector<double> SoapySidekiq::listSampleRates(const int direction, const siz
void SoapySidekiq::setBandwidth(const int direction, const size_t channel, const double bw) {
if (direction == SOAPY_SDR_RX) {
rx_bandwidth = (uint32_t) bw;
if (skiq_write_rx_sample_rate_and_bandwidth(card, rx_hdl, rx_sample_rate, rx_bandwidth) < 0) {
if (skiq_write_rx_sample_rate_and_bandwidth(card, rx_hdl, rx_sample_rate, rx_bandwidth) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR,
"Failure: skiq_write_rx_sample_rate_and_bandwidth (card %d, sample_rate %d, bandwidth %d)",
card,
Expand All @@ -396,7 +396,7 @@ void SoapySidekiq::setBandwidth(const int direction, const size_t channel, const

if (direction == SOAPY_SDR_TX) {
tx_bandwidth = (uint32_t) bw;
if (skiq_write_tx_sample_rate_and_bandwidth(card, tx_hdl, tx_sample_rate, tx_bandwidth) < 0) {
if (skiq_write_tx_sample_rate_and_bandwidth(card, tx_hdl, tx_sample_rate, tx_bandwidth) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR,
"Failure: skiq_write_tx_sample_rate_and_bandwidth (card %d, sample_rate %d, bandwidth %d)",
card,
Expand All @@ -412,13 +412,13 @@ double SoapySidekiq::getBandwidth(const int direction, const size_t channel) con
uint32_t bandwidth;
uint32_t actual_bandwidth;
if (direction == SOAPY_SDR_RX) {
if (skiq_read_rx_sample_rate_and_bandwidth(card, rx_hdl, &rate, &actual_rate, &bandwidth, &actual_bandwidth) < 0) {
if (skiq_read_rx_sample_rate_and_bandwidth(card, rx_hdl, &rate, &actual_rate, &bandwidth, &actual_bandwidth) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_rx_sample_rate_and_bandwidth (card %d)", card);
}
}

if (direction == SOAPY_SDR_TX) {
if (skiq_read_tx_sample_rate_and_bandwidth(card, tx_hdl, &rate, &actual_rate, &bandwidth, &actual_bandwidth) < 0) {
if (skiq_read_tx_sample_rate_and_bandwidth(card, tx_hdl, &rate, &actual_rate, &bandwidth, &actual_bandwidth) != 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Failure: skiq_read_tx_sample_rate_and_bandwidth (card %d)", card);
}
}
Expand Down
6 changes: 5 additions & 1 deletion SoapySidekiq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <SoapySDR/Types.hpp>

#define DEFAULT_BUFFER_LENGTH (65536)
#define DEFAULT_NUM_BUFFERS (8)
#define DEFAULT_NUM_BUFFERS (10)
#define DEFAULT_ELEMS_PER_SAMPLE (2)

class SoapySidekiq : public SoapySDR::Device {
Expand Down Expand Up @@ -208,6 +208,10 @@ class SoapySidekiq : public SoapySDR::Device {
std::string readSetting(const std::string &key) const;

private:

SoapySDR::Stream* const TX_STREAM = (SoapySDR::Stream*) 0x1;
SoapySDR::Stream* const RX_STREAM = (SoapySDR::Stream*) 0x2;

// sidekiq card
uint8_t card;

Expand Down
Loading

0 comments on commit e52ac7f

Please sign in to comment.