Skip to content

Commit c09b2f1

Browse files
Merge pull request #84 from pothosware/ref_clock_rate_support
Ref clock rate support
2 parents c7ebc41 + 84d8e29 commit c09b2f1

5 files changed

Lines changed: 192 additions & 4 deletions

File tree

Changelog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Release 0.6.0 (pending)
2+
==========================
3+
4+
- Added support for ref clock rate API
5+
- Added support for IQ balance auto API
6+
17
Release 0.5.3 (pending)
28
==========================
39

client/Settings.cpp

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2015-2017 Josh Blum
1+
// Copyright (c) 2015-2020 Josh Blum
22
// Copyright (c) 2016-2016 Bastille Networks
33
// SPDX-License-Identifier: BSL-1.0
44

@@ -383,6 +383,49 @@ bool SoapyRemoteDevice::hasFrequencyCorrection(const int direction, const size_t
383383
return result;
384384
}
385385

386+
bool SoapyRemoteDevice::hasIQBalanceMode(const int direction, const size_t channel) const
387+
{
388+
std::lock_guard<std::mutex> lock(_mutex);
389+
SoapyRPCPacker packer(_sock);
390+
packer & SOAPY_REMOTE_HAS_IQ_BALANCE_MODE_AUTO;
391+
packer & char(direction);
392+
packer & int(channel);
393+
packer();
394+
395+
SoapyRPCUnpacker unpacker(_sock);
396+
bool result;
397+
unpacker & result;
398+
return result;
399+
}
400+
401+
void SoapyRemoteDevice::setIQBalanceMode(const int direction, const size_t channel, const bool automatic)
402+
{
403+
std::lock_guard<std::mutex> lock(_mutex);
404+
SoapyRPCPacker packer(_sock);
405+
packer & SOAPY_REMOTE_SET_IQ_BALANCE_MODE_AUTO;
406+
packer & char(direction);
407+
packer & int(channel);
408+
packer & automatic;
409+
packer();
410+
411+
SoapyRPCUnpacker unpacker(_sock);
412+
}
413+
414+
bool SoapyRemoteDevice::getIQBalanceMode(const int direction, const size_t channel) const
415+
{
416+
std::lock_guard<std::mutex> lock(_mutex);
417+
SoapyRPCPacker packer(_sock);
418+
packer & SOAPY_REMOTE_GET_IQ_BALANCE_MODE_AUTO;
419+
packer & char(direction);
420+
packer & int(channel);
421+
packer();
422+
423+
SoapyRPCUnpacker unpacker(_sock);
424+
bool result;
425+
unpacker & result;
426+
return result;
427+
}
428+
386429
void SoapyRemoteDevice::setFrequencyCorrection(const int direction, const size_t channel, const double value)
387430
{
388431
std::lock_guard<std::mutex> lock(_mutex);
@@ -852,6 +895,43 @@ SoapySDR::RangeList SoapyRemoteDevice::getMasterClockRates(void) const
852895
return result;
853896
}
854897

898+
void SoapyRemoteDevice::setReferenceClockRate(const double rate)
899+
{
900+
std::lock_guard<std::mutex> lock(_mutex);
901+
SoapyRPCPacker packer(_sock);
902+
packer & SOAPY_REMOTE_SET_REF_CLOCK_RATE;
903+
packer & rate;
904+
packer();
905+
906+
SoapyRPCUnpacker unpacker(_sock);
907+
}
908+
909+
double SoapyRemoteDevice::getReferenceClockRate(void) const
910+
{
911+
std::lock_guard<std::mutex> lock(_mutex);
912+
SoapyRPCPacker packer(_sock);
913+
packer & SOAPY_REMOTE_GET_REF_CLOCK_RATE;
914+
packer();
915+
916+
SoapyRPCUnpacker unpacker(_sock);
917+
double result;
918+
unpacker & result;
919+
return result;
920+
}
921+
922+
SoapySDR::RangeList SoapyRemoteDevice::getReferenceClockRates(void) const
923+
{
924+
std::lock_guard<std::mutex> lock(_mutex);
925+
SoapyRPCPacker packer(_sock);
926+
packer & SOAPY_REMOTE_GET_REF_CLOCK_RATES;
927+
packer();
928+
929+
SoapyRPCUnpacker unpacker(_sock);
930+
SoapySDR::RangeList result;
931+
unpacker & result;
932+
return result;
933+
}
934+
855935
std::vector<std::string> SoapyRemoteDevice::listClockSources(void) const
856936
{
857937
std::lock_guard<std::mutex> lock(_mutex);

client/SoapyClient.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2015-2018 Josh Blum
1+
// Copyright (c) 2015-2020 Josh Blum
22
// Copyright (c) 2016-2016 Bastille Networks
33
// SPDX-License-Identifier: BSL-1.0
44

@@ -164,6 +164,12 @@ class SoapyRemoteDevice : public SoapySDR::Device
164164

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

167+
bool hasIQBalanceMode(const int direction, const size_t channel) const;
168+
169+
void setIQBalanceMode(const int direction, const size_t channel, const bool automatic);
170+
171+
bool getIQBalanceMode(const int direction, const size_t channel) const;
172+
167173
bool hasFrequencyCorrection(const int direction, const size_t channel) const;
168174

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

249255
SoapySDR::RangeList getMasterClockRates(void) const;
250256

257+
void setReferenceClockRate(const double rate);
258+
259+
double getReferenceClockRate(void) const;
260+
261+
SoapySDR::RangeList getReferenceClockRates(void) const;
262+
251263
std::vector<std::string> listClockSources(void) const;
252264

253265
void setClockSource(const std::string &source);

common/SoapyRemoteDefs.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2015-2018 Josh Blum
1+
// Copyright (c) 2015-2020 Josh Blum
22
// Copyright (c) 2016-2016 Bastille Networks
33
// SPDX-License-Identifier: BSL-1.0
44

@@ -177,6 +177,9 @@ enum SoapyRemoteCalls
177177
SOAPY_REMOTE_HAS_IQ_BALANCE_MODE = 606,
178178
SOAPY_REMOTE_SET_IQ_BALANCE_MODE = 607,
179179
SOAPY_REMOTE_GET_IQ_BALANCE_MODE = 608,
180+
SOAPY_REMOTE_HAS_IQ_BALANCE_MODE_AUTO = 609,
181+
SOAPY_REMOTE_SET_IQ_BALANCE_MODE_AUTO = 610,
182+
SOAPY_REMOTE_GET_IQ_BALANCE_MODE_AUTO = 611,
180183
SOAPY_REMOTE_HAS_FREQUENCY_CORRECTION = 503,
181184
SOAPY_REMOTE_SET_FREQUENCY_CORRECTION = 504,
182185
SOAPY_REMOTE_GET_FREQUENCY_CORRECTION = 505,
@@ -222,6 +225,9 @@ enum SoapyRemoteCalls
222225
SOAPY_REMOTE_SET_CLOCK_SOURCE = 1003,
223226
SOAPY_REMOTE_GET_CLOCK_SOURCE = 1004,
224227
SOAPY_REMOTE_GET_MASTER_CLOCK_RATES = 1008,
228+
SOAPY_REMOTE_SET_REF_CLOCK_RATE = 1009,
229+
SOAPY_REMOTE_GET_REF_CLOCK_RATE = 1010,
230+
SOAPY_REMOTE_GET_REF_CLOCK_RATES = 1011,
225231

226232
//time
227233
SOAPY_REMOTE_LIST_TIME_SOURCES = 1005,

server/ClientHandler.cpp

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2015-2018 Josh Blum
1+
// Copyright (c) 2015-2020 Josh Blum
22
// Copyright (c) 2016-2016 Bastille Networks
33
// SPDX-License-Identifier: BSL-1.0
44

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

645+
////////////////////////////////////////////////////////////////////
646+
case SOAPY_REMOTE_HAS_IQ_BALANCE_MODE_AUTO:
647+
////////////////////////////////////////////////////////////////////
648+
{
649+
char direction = 0;
650+
int channel = 0;
651+
unpacker & direction;
652+
unpacker & channel;
653+
#ifdef SOAPY_SDR_API_HAS_IQ_BALANCE_MODE
654+
packer & _dev->hasIQBalanceMode(direction, channel);
655+
#else
656+
bool result(false);
657+
packer & result;
658+
#endif
659+
} break;
660+
661+
////////////////////////////////////////////////////////////////////
662+
case SOAPY_REMOTE_SET_IQ_BALANCE_MODE_AUTO:
663+
////////////////////////////////////////////////////////////////////
664+
{
665+
char direction = 0;
666+
int channel = 0;
667+
bool automatic = false;
668+
unpacker & direction;
669+
unpacker & channel;
670+
unpacker & automatic;
671+
#ifdef SOAPY_SDR_API_HAS_IQ_BALANCE_MODE
672+
_dev->setIQBalanceMode(direction, channel, automatic);
673+
#endif
674+
packer & SOAPY_REMOTE_VOID;
675+
} break;
676+
677+
////////////////////////////////////////////////////////////////////
678+
case SOAPY_REMOTE_GET_IQ_BALANCE_MODE_AUTO:
679+
////////////////////////////////////////////////////////////////////
680+
{
681+
char direction = 0;
682+
int channel = 0;
683+
unpacker & direction;
684+
unpacker & channel;
685+
#ifdef SOAPY_SDR_API_HAS_IQ_BALANCE_MODE
686+
packer & _dev->getIQBalanceMode(direction, channel);
687+
#else
688+
bool result(false);
689+
packer & result;
690+
#endif
691+
} break;
692+
645693
////////////////////////////////////////////////////////////////////
646694
case SOAPY_REMOTE_HAS_FREQUENCY_CORRECTION:
647695
////////////////////////////////////////////////////////////////////
@@ -1048,6 +1096,42 @@ bool SoapyClientHandler::handleOnce(SoapyRPCUnpacker &unpacker, SoapyRPCPacker &
10481096
packer & _dev->getMasterClockRates();
10491097
} break;
10501098

1099+
////////////////////////////////////////////////////////////////////
1100+
case SOAPY_REMOTE_SET_REF_CLOCK_RATE:
1101+
////////////////////////////////////////////////////////////////////
1102+
{
1103+
double rate = 0;
1104+
unpacker & rate;
1105+
#ifdef SOAPY_SDR_API_HAS_REF_CLOCK_RATE_API
1106+
_dev->setReferenceClockRate(rate);
1107+
#endif
1108+
packer & SOAPY_REMOTE_VOID;
1109+
} break;
1110+
1111+
////////////////////////////////////////////////////////////////////
1112+
case SOAPY_REMOTE_GET_REF_CLOCK_RATE:
1113+
////////////////////////////////////////////////////////////////////
1114+
{
1115+
#ifdef SOAPY_SDR_API_HAS_REF_CLOCK_RATE_API
1116+
packer & _dev->getReferenceClockRate();
1117+
#else
1118+
double result;
1119+
packer & result;
1120+
#endif
1121+
} break;
1122+
1123+
////////////////////////////////////////////////////////////////////
1124+
case SOAPY_REMOTE_GET_REF_CLOCK_RATES:
1125+
////////////////////////////////////////////////////////////////////
1126+
{
1127+
#ifdef SOAPY_SDR_API_HAS_REF_CLOCK_RATE_API
1128+
packer & _dev->getReferenceClockRates();
1129+
#else
1130+
SoapySDR::RangeList result;
1131+
packer & result;
1132+
#endif
1133+
} break;
1134+
10511135
////////////////////////////////////////////////////////////////////
10521136
case SOAPY_REMOTE_LIST_CLOCK_SOURCES:
10531137
////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)