Skip to content

Commit

Permalink
Merge pull request #180 from cjcliffe/soapy-settings
Browse files Browse the repository at this point in the history
SoapySDR Settings support
  • Loading branch information
cjcliffe committed Nov 8, 2015
2 parents 0d92854 + f39a960 commit 02b06ea
Show file tree
Hide file tree
Showing 16 changed files with 795 additions and 737 deletions.
49 changes: 45 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.8)

SET(CUBICSDR_VERSION_MAJOR "0")
SET(CUBICSDR_VERSION_MINOR "1")
SET(CUBICSDR_VERSION_PATCH "15")
SET(CUBICSDR_VERSION_PATCH "16")
SET(CUBICSDR_VERSION_REL "alpha")
SET(CUBICSDR_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}-${CUBICSDR_VERSION_REL}")

Expand Down Expand Up @@ -425,6 +425,14 @@ IF (APPLE AND BUNDLE_APP)
PROJECT(CubicSDR)
SET(MACOSX_BUNDLE_BUNDLE_NAME CubicSDR)

set(BUNDLE_SOAPY_MODS OFF CACHE BOOL "Bundle local SoapySDR modules")

IF (BUNDLE_SOAPY_MODS)
ADD_DEFINITIONS(
-DBUNDLE_SOAPY_MODS=1
)
ENDIF()

ADD_DEFINITIONS(
-std=c++0x
-pthread
Expand Down Expand Up @@ -466,7 +474,7 @@ IF (APPLE AND BUNDLE_APP)
${PROJECT_SOURCE_DIR}/icon/CubicSDR.icns
PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
)

target_link_libraries(CubicSDR ${LIQUID_LIB} ${FFTW_LIB} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} ${OTHER_LIBRARIES})
SET_TARGET_PROPERTIES(CubicSDR PROPERTIES MACOSX_BUNDLE TRUE)
Expand All @@ -478,16 +486,49 @@ IF (APPLE AND BUNDLE_APP)
# MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.cubicproductions.cubicsdr"
MACOSX_BUNDLE_ICON_FILE CubicSDR.icns
)
)

SET(APPS "${CMAKE_BINARY_DIR}/${EX_PLATFORM_NAME}/CubicSDR.app")
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
# SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

IF (BUNDLE_SOAPY_MODS)

message(STATUS "SOAPY_ROOT: ${SOAPY_SDR_ROOT}")
file(GLOB SOAPY_MODS ${SOAPY_SDR_ROOT}/lib/SoapySDR/modules/*.so)

FOREACH(SOAPY_MOD_FILE ${SOAPY_MODS})
INSTALL( FILES "${SOAPY_MOD_FILE}"
DESTINATION "${APPS}/Contents/MacOS/modules"
COMPONENT Runtime
)
ENDFOREACH()

ENDIF(BUNDLE_SOAPY_MODS)

INSTALL(CODE "
SET(BU_COPY_FULL_FRAMEWORK_CONTENTS ON)
SET(BU_COPY_FULL_FRAMEWORK_CONTENTS ON)
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"/usr/local/lib\")
" COMPONENT Runtime)

IF (BUNDLE_SOAPY_MODS)
FOREACH(SOAPY_MOD_FILE ${SOAPY_MODS})
GET_FILENAME_COMPONENT(SOAPY_MOD_NAME ${SOAPY_MOD_FILE} NAME)

IF(${SOAPY_MOD_NAME} STREQUAL "libsdrPlaySupport.so") # prevent inclusion of libmirsdrapi-rsp.so
message(STATUS "Excluding libsdrPlaySupport.so")
CONTINUE()
ELSE()
message(STATUS "Bundling ${SOAPY_MOD_NAME} from ${SOAPY_MOD_FILE}")
ENDIF()
INSTALL(CODE "
fixup_bundle(\"${APPS}\" \"${APPS}/Contents/MacOS/modules/${SOAPY_MOD_NAME}\" \"/usr/local/lib\")
" COMPONENT Runtime)
ENDFOREACH()
ENDIF(BUNDLE_SOAPY_MODS)

INSTALL(CODE "
VERIFY_APP(\"${APPS}\")
" COMPONENT Runtime)

Expand Down
46 changes: 0 additions & 46 deletions src/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
#include "CubicSDR.h"

DeviceConfig::DeviceConfig() : deviceId("") {
iqSwap.store(0);
ppm.store(0);
directSampling.store(false);
offset.store(0);
}

Expand All @@ -20,14 +18,6 @@ int DeviceConfig::getPPM() {
return ppm.load();
}

void DeviceConfig::setDirectSampling(int mode) {
directSampling.store(mode);
}

int DeviceConfig::getDirectSampling() {
return directSampling.load();
}

void DeviceConfig::setOffset(long long offset) {
this->offset.store(offset);
}
Expand All @@ -36,14 +26,6 @@ long long DeviceConfig::getOffset() {
return offset.load();
}

void DeviceConfig::setIQSwap(bool iqSwap) {
this->iqSwap.store(iqSwap);
}

bool DeviceConfig::getIQSwap() {
return iqSwap.load();
}

void DeviceConfig::setDeviceId(std::string deviceId) {
busy_lock.lock();
this->deviceId = deviceId;
Expand All @@ -64,8 +46,6 @@ void DeviceConfig::save(DataNode *node) {
busy_lock.lock();
*node->newChild("id") = deviceId;
*node->newChild("ppm") = (int)ppm;
*node->newChild("iq_swap") = iqSwap;
*node->newChild("direct_sampling") = directSampling;
*node->newChild("offset") = offset;
busy_lock.unlock();
}
Expand All @@ -79,32 +59,6 @@ void DeviceConfig::load(DataNode *node) {
setPPM(ppmValue);
std::cout << "Loaded PPM for device '" << deviceId << "' at " << ppmValue << "ppm" << std::endl;
}
if (node->hasAnother("iq_swap")) {
DataNode *iq_swap_node = node->getNext("iq_swap");
int iqSwapValue = 0;
iq_swap_node->element()->get(iqSwapValue);
setIQSwap(iqSwapValue?true:false);
std::cout << "Loaded I/Q Swap for device '" << deviceId << "' as " << (iqSwapValue?"swapped":"not swapped") << std::endl;
}
if (node->hasAnother("direct_sampling")) {
DataNode *direct_sampling_node = node->getNext("direct_sampling");
int directSamplingValue = 0;
direct_sampling_node->element()->get(directSamplingValue);
setDirectSampling(directSamplingValue);
std::cout << "Loaded Direct Sampling Mode for device '" << deviceId << "': ";
switch (directSamplingValue) {
case 0:
std::cout << "off" << std::endl;
break;
case 1:
std::cout << "I-ADC" << std::endl;
break;
case 2:
std::cout << "Q-ADC" << std::endl;
break;

}
}
if (node->hasAnother("offset")) {
DataNode *offset_node = node->getNext("offset");
long long offsetValue = 0;
Expand Down
9 changes: 1 addition & 8 deletions src/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@ class DeviceConfig {
void setPPM(int ppm);
int getPPM();

void setDirectSampling(int mode);
int getDirectSampling();

void setOffset(long long offset);
long long getOffset();

void setIQSwap(bool iqSwap);
bool getIQSwap();

void setDeviceId(std::string deviceId);
std::string getDeviceId();

Expand All @@ -36,8 +30,7 @@ class DeviceConfig {
std::string deviceId;
std::mutex busy_lock;

std::atomic_int ppm, directSampling;
std::atomic_bool iqSwap;
std::atomic_int ppm;
std::atomic_llong offset;
};

Expand Down
Loading

0 comments on commit 02b06ea

Please sign in to comment.