Skip to content

Commit

Permalink
Merge pull request #84 from pothosware/ref_clock_rate_support
Browse files Browse the repository at this point in the history
Ref clock rate support
  • Loading branch information
guruofquality authored Nov 5, 2020
2 parents c7ebc41 + 84d8e29 commit c09b2f1
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Release 0.6.0 (pending)
==========================

- Added support for ref clock rate API
- Added support for IQ balance auto API

Release 0.5.3 (pending)
==========================

Expand Down
82 changes: 81 additions & 1 deletion client/Settings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015-2017 Josh Blum
// Copyright (c) 2015-2020 Josh Blum
// Copyright (c) 2016-2016 Bastille Networks
// SPDX-License-Identifier: BSL-1.0

Expand Down Expand Up @@ -383,6 +383,49 @@ bool SoapyRemoteDevice::hasFrequencyCorrection(const int direction, const size_t
return result;
}

bool SoapyRemoteDevice::hasIQBalanceMode(const int direction, const size_t channel) const
{
std::lock_guard<std::mutex> lock(_mutex);
SoapyRPCPacker packer(_sock);
packer & SOAPY_REMOTE_HAS_IQ_BALANCE_MODE_AUTO;
packer & char(direction);
packer & int(channel);
packer();

SoapyRPCUnpacker unpacker(_sock);
bool result;
unpacker & result;
return result;
}

void SoapyRemoteDevice::setIQBalanceMode(const int direction, const size_t channel, const bool automatic)
{
std::lock_guard<std::mutex> lock(_mutex);
SoapyRPCPacker packer(_sock);
packer & SOAPY_REMOTE_SET_IQ_BALANCE_MODE_AUTO;
packer & char(direction);
packer & int(channel);
packer & automatic;
packer();

SoapyRPCUnpacker unpacker(_sock);
}

bool SoapyRemoteDevice::getIQBalanceMode(const int direction, const size_t channel) const
{
std::lock_guard<std::mutex> lock(_mutex);
SoapyRPCPacker packer(_sock);
packer & SOAPY_REMOTE_GET_IQ_BALANCE_MODE_AUTO;
packer & char(direction);
packer & int(channel);
packer();

SoapyRPCUnpacker unpacker(_sock);
bool result;
unpacker & result;
return result;
}

void SoapyRemoteDevice::setFrequencyCorrection(const int direction, const size_t channel, const double value)
{
std::lock_guard<std::mutex> lock(_mutex);
Expand Down Expand Up @@ -852,6 +895,43 @@ SoapySDR::RangeList SoapyRemoteDevice::getMasterClockRates(void) const
return result;
}

void SoapyRemoteDevice::setReferenceClockRate(const double rate)
{
std::lock_guard<std::mutex> lock(_mutex);
SoapyRPCPacker packer(_sock);
packer & SOAPY_REMOTE_SET_REF_CLOCK_RATE;
packer & rate;
packer();

SoapyRPCUnpacker unpacker(_sock);
}

double SoapyRemoteDevice::getReferenceClockRate(void) const
{
std::lock_guard<std::mutex> lock(_mutex);
SoapyRPCPacker packer(_sock);
packer & SOAPY_REMOTE_GET_REF_CLOCK_RATE;
packer();

SoapyRPCUnpacker unpacker(_sock);
double result;
unpacker & result;
return result;
}

SoapySDR::RangeList SoapyRemoteDevice::getReferenceClockRates(void) const
{
std::lock_guard<std::mutex> lock(_mutex);
SoapyRPCPacker packer(_sock);
packer & SOAPY_REMOTE_GET_REF_CLOCK_RATES;
packer();

SoapyRPCUnpacker unpacker(_sock);
SoapySDR::RangeList result;
unpacker & result;
return result;
}

std::vector<std::string> SoapyRemoteDevice::listClockSources(void) const
{
std::lock_guard<std::mutex> lock(_mutex);
Expand Down
14 changes: 13 additions & 1 deletion client/SoapyClient.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015-2018 Josh Blum
// Copyright (c) 2015-2020 Josh Blum
// Copyright (c) 2016-2016 Bastille Networks
// SPDX-License-Identifier: BSL-1.0

Expand Down Expand Up @@ -164,6 +164,12 @@ class SoapyRemoteDevice : public SoapySDR::Device

std::complex<double> getIQBalance(const int direction, const size_t channel) const;

bool hasIQBalanceMode(const int direction, const size_t channel) const;

void setIQBalanceMode(const int direction, const size_t channel, const bool automatic);

bool getIQBalanceMode(const int direction, const size_t channel) const;

bool hasFrequencyCorrection(const int direction, const size_t channel) const;

void setFrequencyCorrection(const int direction, const size_t channel, const double value);
Expand Down Expand Up @@ -248,6 +254,12 @@ class SoapyRemoteDevice : public SoapySDR::Device

SoapySDR::RangeList getMasterClockRates(void) const;

void setReferenceClockRate(const double rate);

double getReferenceClockRate(void) const;

SoapySDR::RangeList getReferenceClockRates(void) const;

std::vector<std::string> listClockSources(void) const;

void setClockSource(const std::string &source);
Expand Down
8 changes: 7 additions & 1 deletion common/SoapyRemoteDefs.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015-2018 Josh Blum
// Copyright (c) 2015-2020 Josh Blum
// Copyright (c) 2016-2016 Bastille Networks
// SPDX-License-Identifier: BSL-1.0

Expand Down Expand Up @@ -177,6 +177,9 @@ enum SoapyRemoteCalls
SOAPY_REMOTE_HAS_IQ_BALANCE_MODE = 606,
SOAPY_REMOTE_SET_IQ_BALANCE_MODE = 607,
SOAPY_REMOTE_GET_IQ_BALANCE_MODE = 608,
SOAPY_REMOTE_HAS_IQ_BALANCE_MODE_AUTO = 609,
SOAPY_REMOTE_SET_IQ_BALANCE_MODE_AUTO = 610,
SOAPY_REMOTE_GET_IQ_BALANCE_MODE_AUTO = 611,
SOAPY_REMOTE_HAS_FREQUENCY_CORRECTION = 503,
SOAPY_REMOTE_SET_FREQUENCY_CORRECTION = 504,
SOAPY_REMOTE_GET_FREQUENCY_CORRECTION = 505,
Expand Down Expand Up @@ -222,6 +225,9 @@ enum SoapyRemoteCalls
SOAPY_REMOTE_SET_CLOCK_SOURCE = 1003,
SOAPY_REMOTE_GET_CLOCK_SOURCE = 1004,
SOAPY_REMOTE_GET_MASTER_CLOCK_RATES = 1008,
SOAPY_REMOTE_SET_REF_CLOCK_RATE = 1009,
SOAPY_REMOTE_GET_REF_CLOCK_RATE = 1010,
SOAPY_REMOTE_GET_REF_CLOCK_RATES = 1011,

//time
SOAPY_REMOTE_LIST_TIME_SOURCES = 1005,
Expand Down
86 changes: 85 additions & 1 deletion server/ClientHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015-2018 Josh Blum
// Copyright (c) 2015-2020 Josh Blum
// Copyright (c) 2016-2016 Bastille Networks
// SPDX-License-Identifier: BSL-1.0

Expand Down Expand Up @@ -642,6 +642,54 @@ bool SoapyClientHandler::handleOnce(SoapyRPCUnpacker &unpacker, SoapyRPCPacker &
packer & _dev->getIQBalance(direction, channel);
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_HAS_IQ_BALANCE_MODE_AUTO:
////////////////////////////////////////////////////////////////////
{
char direction = 0;
int channel = 0;
unpacker & direction;
unpacker & channel;
#ifdef SOAPY_SDR_API_HAS_IQ_BALANCE_MODE
packer & _dev->hasIQBalanceMode(direction, channel);
#else
bool result(false);
packer & result;
#endif
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_SET_IQ_BALANCE_MODE_AUTO:
////////////////////////////////////////////////////////////////////
{
char direction = 0;
int channel = 0;
bool automatic = false;
unpacker & direction;
unpacker & channel;
unpacker & automatic;
#ifdef SOAPY_SDR_API_HAS_IQ_BALANCE_MODE
_dev->setIQBalanceMode(direction, channel, automatic);
#endif
packer & SOAPY_REMOTE_VOID;
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_GET_IQ_BALANCE_MODE_AUTO:
////////////////////////////////////////////////////////////////////
{
char direction = 0;
int channel = 0;
unpacker & direction;
unpacker & channel;
#ifdef SOAPY_SDR_API_HAS_IQ_BALANCE_MODE
packer & _dev->getIQBalanceMode(direction, channel);
#else
bool result(false);
packer & result;
#endif
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_HAS_FREQUENCY_CORRECTION:
////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1048,6 +1096,42 @@ bool SoapyClientHandler::handleOnce(SoapyRPCUnpacker &unpacker, SoapyRPCPacker &
packer & _dev->getMasterClockRates();
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_SET_REF_CLOCK_RATE:
////////////////////////////////////////////////////////////////////
{
double rate = 0;
unpacker & rate;
#ifdef SOAPY_SDR_API_HAS_REF_CLOCK_RATE_API
_dev->setReferenceClockRate(rate);
#endif
packer & SOAPY_REMOTE_VOID;
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_GET_REF_CLOCK_RATE:
////////////////////////////////////////////////////////////////////
{
#ifdef SOAPY_SDR_API_HAS_REF_CLOCK_RATE_API
packer & _dev->getReferenceClockRate();
#else
double result;
packer & result;
#endif
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_GET_REF_CLOCK_RATES:
////////////////////////////////////////////////////////////////////
{
#ifdef SOAPY_SDR_API_HAS_REF_CLOCK_RATE_API
packer & _dev->getReferenceClockRates();
#else
SoapySDR::RangeList result;
packer & result;
#endif
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_LIST_CLOCK_SOURCES:
////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit c09b2f1

Please sign in to comment.