Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel info and multiple register interfaces #18

Merged
merged 3 commits into from
May 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Release 0.3.0 (pending)
==========================

- Support for named register interface API
- Support for getChannelInfo() API call
- Moved time source calls to time API section
- Support for getBandwidthRange() API call
- Support for channel-specific settings API
Expand Down
57 changes: 57 additions & 0 deletions client/Settings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2015-2016 Josh Blum
// Copyright (c) 2016-2016 Bastille Networks
// SPDX-License-Identifier: BSL-1.0

#include "SoapyClient.hpp"
Expand Down Expand Up @@ -151,6 +152,21 @@ size_t SoapyRemoteDevice::getNumChannels(const int direction) const
return result;
}

SoapySDR::Kwargs SoapyRemoteDevice::getChannelInfo(const int direction, const size_t channel) const
{
std::lock_guard<std::mutex> lock(_mutex);
SoapyRPCPacker packer(_sock);
packer & SOAPY_REMOTE_GET_CHANNEL_INFO;
packer & char(direction);
packer & int(channel);
packer();

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

bool SoapyRemoteDevice::getFullDuplex(const int direction, const size_t channel) const
{
std::lock_guard<std::mutex> lock(_mutex);
Expand Down Expand Up @@ -998,6 +1014,47 @@ std::string SoapyRemoteDevice::readSensor(const int direction, const size_t chan
* Register API
******************************************************************/

std::vector<std::string> SoapyRemoteDevice::listRegisterInterfaces(void) const
{
std::lock_guard<std::mutex> lock(_mutex);
SoapyRPCPacker packer(_sock);
packer & SOAPY_REMOTE_LIST_REGISTER_INTERFACES;
packer();

SoapyRPCUnpacker unpacker(_sock);
std::vector<std::string> result;
unpacker & result;
return result;
}

void SoapyRemoteDevice::writeRegister(const std::string &name, const unsigned addr, const unsigned value)
{
std::lock_guard<std::mutex> lock(_mutex);
SoapyRPCPacker packer(_sock);
packer & SOAPY_REMOTE_WRITE_REGISTER_NAMED;
packer & name;
packer & int(addr);
packer & int(value);
packer();

SoapyRPCUnpacker unpacker(_sock);
}

unsigned SoapyRemoteDevice::readRegister(const std::string &name, const unsigned addr) const
{
std::lock_guard<std::mutex> lock(_mutex);
SoapyRPCPacker packer(_sock);
packer & SOAPY_REMOTE_READ_REGISTER_NAMED;
packer & name;
packer & int(addr);
packer();

SoapyRPCUnpacker unpacker(_sock);
int result;
unpacker & result;
return unsigned(result);
}

void SoapyRemoteDevice::writeRegister(const unsigned addr, const unsigned value)
{
std::lock_guard<std::mutex> lock(_mutex);
Expand Down
9 changes: 9 additions & 0 deletions client/SoapyClient.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2015-2016 Josh Blum
// Copyright (c) 2016-2016 Bastille Networks
// SPDX-License-Identifier: BSL-1.0

#pragma once
Expand Down Expand Up @@ -35,6 +36,8 @@ class SoapyRemoteDevice : public SoapySDR::Device

size_t getNumChannels(const int direction) const;

SoapySDR::Kwargs getChannelInfo(const int direction, const size_t channel) const;

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

/*******************************************************************
Expand Down Expand Up @@ -278,6 +281,12 @@ class SoapyRemoteDevice : public SoapySDR::Device
* Register API
******************************************************************/

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

void writeRegister(const std::string &name, const unsigned addr, const unsigned value);

unsigned readRegister(const std::string &name, const unsigned addr) const;

void writeRegister(const unsigned addr, const unsigned value);

unsigned readRegister(const unsigned addr) const;
Expand Down
5 changes: 5 additions & 0 deletions common/SoapyRemoteDefs.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2015-2016 Josh Blum
// Copyright (c) 2016-2016 Bastille Networks
// SPDX-License-Identifier: BSL-1.0

#pragma once
Expand Down Expand Up @@ -140,6 +141,7 @@ enum SoapyRemoteCalls
SOAPY_REMOTE_GET_FRONTEND_MAPPING = 201,
SOAPY_REMOTE_GET_NUM_CHANNELS = 202,
SOAPY_REMOTE_GET_FULL_DUPLEX = 203,
SOAPY_REMOTE_GET_CHANNEL_INFO = 204,

//stream
SOAPY_REMOTE_SETUP_STREAM = 300,
Expand Down Expand Up @@ -227,6 +229,9 @@ enum SoapyRemoteCalls
//registers
SOAPY_REMOTE_WRITE_REGISTER = 1300,
SOAPY_REMOTE_READ_REGISTER = 1301,
SOAPY_REMOTE_LIST_REGISTER_INTERFACES = 1302,
SOAPY_REMOTE_WRITE_REGISTER_NAMED = 1303,
SOAPY_REMOTE_READ_REGISTER_NAMED = 1304,

//settings
SOAPY_REMOTE_WRITE_SETTING = 1400,
Expand Down
4 changes: 3 additions & 1 deletion debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Upstream-Name: soapyremote
Source: https:/pothosware/SoapyRemote/wiki

Files: *
Copyright: 2015-2015 Josh Blum <[email protected]>
Copyright:
Copyright (c) 2015-2016 Josh Blum <[email protected]>
Copyright (c) 2016-2016 Bastille Networks
License: BSL-1.0
Boost Software License - Version 1.0 - August 17th, 2003
.
Expand Down
61 changes: 61 additions & 0 deletions server/ClientHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2015-2016 Josh Blum
// Copyright (c) 2016-2016 Bastille Networks
// SPDX-License-Identifier: BSL-1.0

#include "ClientHandler.hpp"
Expand Down Expand Up @@ -228,6 +229,22 @@ bool SoapyClientHandler::handleOnce(SoapyRPCUnpacker &unpacker, SoapyRPCPacker &
packer & _dev->getFullDuplex(direction, channel);
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_GET_CHANNEL_INFO:
////////////////////////////////////////////////////////////////////
{
char direction = 0;
int channel = 0;
unpacker & direction;
unpacker & channel;
#ifdef SOAPY_SDR_API_HAS_GET_CHANNEL_INFO
packer & _dev->getChannelInfo(direction, channel);
#else
SoapySDR::Kwargs result;
packer & result;
#endif
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_GET_STREAM_FORMATS:
////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1066,6 +1083,50 @@ bool SoapyClientHandler::handleOnce(SoapyRPCUnpacker &unpacker, SoapyRPCPacker &
packer & int(_dev->readRegister(unsigned(addr)));
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_LIST_REGISTER_INTERFACES:
////////////////////////////////////////////////////////////////////
{
#ifdef SOAPY_SDR_API_HAS_NAMED_REGISTER_API
packer & _dev->listRegisterInterfaces();
#else
std::vector<std::string> result;
packer & result;
#endif
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_WRITE_REGISTER_NAMED:
////////////////////////////////////////////////////////////////////
{
std::string name;
int addr = 0;
int value = 0;
unpacker & name;
unpacker & addr;
unpacker & value;
#ifdef SOAPY_SDR_API_HAS_NAMED_REGISTER_API
_dev->writeRegister(name, unsigned(addr), unsigned(value));
#endif
packer & SOAPY_REMOTE_VOID;
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_READ_REGISTER_NAMED:
////////////////////////////////////////////////////////////////////
{
std::string name;
int addr = 0;
unpacker & name;
unpacker & addr;
#ifdef SOAPY_SDR_API_HAS_NAMED_REGISTER_API
packer & int(_dev->readRegister(name, unsigned(addr)));
#else
int result = 0;
packer & result;
#endif
} break;

////////////////////////////////////////////////////////////////////
case SOAPY_REMOTE_GET_SETTING_INFO:
////////////////////////////////////////////////////////////////////
Expand Down